Reputation: 8352
How to write a jquery selector to match an element has attribute a or attribute b. It must match three elements below
<a a="123" b="345"></a>
<a a="123"></a>
<a b="345"></a>
Upvotes: 3
Views: 3290
Reputation: 3330
Try this
$('a[b="345"],a[a=123] ')
See the jQuery Multiple selector docs.
Upvotes: 5
Reputation: 630637
You can use a multiple selector (,
) with the attribute-equals selector (or any other selectors), for example:
$("a[a=123], a[b=345]")
Upvotes: 8