Reputation: 4517
I want to be able to select all elements that have one of a list of attributes.
For example, I want to select all elements that have either a mandatory
attribute, or validate='true'
or both.
I tried this:
$('[mandatory="true",validate]').each(...
But I get an error.
I can't find any alternatives online. Any suggestions?
Thanks
Upvotes: 1
Views: 1994
Reputation: 382092
To select "all elements that have either a mandatory attribute, or validate='true' or both", use
$('[mandatory],[validate="true"]')
If what you really want is to have at least one of those attributes with value "true", use
$('[mandatory="true"],[validate="true"]')
Regarding your comment : if you wanted to select elements having both attributes, you'd simply remove the comma.
Upvotes: 8