Reputation: 5789
How do I write a selector that has two condtional selectors, eg
$("#version option:selected **AND** option:contains('some text')")
Upvotes: 3
Views: 478
Reputation: 20645
You separate the selectors by commas:
$("#version option:selected,#version option:contains('some text')")
http://api.jquery.com/multiple-selector/
Update
Even though this is not what the OP was looking for I updated my post in case someone stumbles upon this in the future. Thanks to RoToRa for catching the error.
Upvotes: 0
Reputation: 9361
You can match on multiple attribute selectors by simply chaining further sub 'find' calls.
For example:
$("#version option:selected").find(":contains('some text')") //and so forth
Upvotes: 1
Reputation: 22438
Just like you can use :visited:hover
in CSS, you could do the same in jQuery:
$("#version option:selected:contains('some text')")
Upvotes: 7
Reputation: 38410
http://api.jquery.com/multiple-selector/
BTW, the correct usage would be in your case:
$("#version option:selected, #version option:contains('some text')")
or
$("#version").find("option:selected, option:contains('some text')")
not
$("#version option:selected, option:contains('some text')")
Upvotes: 1