Satpal's answer is pretty good (I like that the selector is restricted to only
elements; that will be a little faster than searching the whole DOM).
I would like to suggest, though, that you use multiple data attributes. For example:
I'm Matched
I'm Matched Too
I'm Matched Too
I'm Not Matched
Or classes:
I'm Matched
I'm Matched Too
I'm Matched Too
I'm Not Matched
In in this way, you can match one one thing (either data-foo
or class foo
), and get the specificity you need as well.