Reputation: 11205
I want to select the input element in my html with a certain class
and name
:
<input type="checkbox" value="Delete" name="foo" class="Row0"/>
<input type="checkbox" value="Delete" name="foo" class="Row1"/>
<input type="checkbox" value="Delete" name="foo" class="Row2"/>
I know that I can combine selectors using comma as:
"selector1, selector2, selectorN"
So I write the selector as:
'input[name=foo]:checked,input[class=Row0]'
But that performs or on the selectors as it returns elements matching either of the above selectors.What if I want to get elements matching all the above selectors,i.e. perform and on the selectors?
Upvotes: 0
Views: 47
Reputation: 39532
Just add extra brackets:
input[name=foo][class=Row0]:checked
or simply use the class selector (which is essentially the same - might work better cache-wise):
input.Row0[name=foo]:checked
Means an input field with the attribute name
set to foo
, the attribute class
set to Row0
and it must be checked.
If you want to exclude elements, you can use the :not
selector:
input[name=foo]:checked:not(.Row0)
Meaning an input field with the attribute name
set to foo
and it must be checked, however it cannot have the class Row0
.
Upvotes: 4