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

22 Replies, 1860 Views

The `*=` operator is perfect for partial matches in an html query selector element. No need for regex unless you’re doing something wild.

Pro tip: If your classes have multiple names (like `btn-primary large`), `[class~="btn-"]` won’t work—it’s for whole words. Stick with `*=` or `^=` for flexibility.

MDN’s docs on attribute selectors are gold for this.

Messages In This Thread



Users browsing this thread: 1 Guest(s)