How do I target an HTML query selector element that contains a partial class? or What's the best way

22 Replies, 1815 Views

`[class*="btn-"]` is the move! It’s clean and does exactly what you need for partial class matching.

If you’re paranoid about edge cases (like `old-btn-new`), `[class^="btn-"]` or `[class|="btn"]` might help.

Regex is cool but way heavier. Only use it if CSS can’t hack it.

Messages In This Thread



Users browsing this thread: 1 Guest(s)