Reputation: 25965
At the moment, the result of .is()
will return true if ANY (OR) of the conditions are true
, how do I make it use AND instead, i.e. only return true
if ALL conditions are met?
if ($('#search-form #valid_only').is(':checked, :enabled')) {
}
Upvotes: 3
Views: 81
Reputation: 66663
That comma in your selector is equivalent to an OR.
Use both conditions without a comma separating them inside is()
if ($('#search-form #valid_only').is(':checked:enabled') { // checked and enabled
...
}
Or if you want to check for :checked
, :enabled
and having a class name foo
, you can do .foo:checked:enabled
Upvotes: 5
Reputation: 2960
You can just combine your selectors:
if ($('#search-form #valid-only').is(':checked:enabled')) {
}
Upvotes: 2