Reputation: 52952
Assuming I create something like:
<div>
<p myAttribute='Hello'>Text</p>
..
</div>
I then want to find on my page, all elements that have myAttribute, regardless of what they are. How do I do this?
Upvotes: 3
Views: 1491
Reputation: 630627
You can use the has-attribute selector, for example:
$("[myAttribute]")
To get elements with that attribute with that specific value, use the attribute-equals selector, like this:
$("[myAttribute='Hello']")
You can find the full list of Attribute Selectors available here.
Upvotes: 10