Quick question:
let's say you have 2 different types of <button>
,
First one looks something like this: <button class="test">
Second looks like this: <button class="test" disabled="disabled">
.
Now, how can one achieve a selection of the disabled button without selecting the activated
button? Cause if you go by class, querySelector
would get both of them. Is there a way to implement some kind of logic into the selection made by querySelector
?
Something like this maybe -> "select button with class 'test' AND NOT attribute 'disabled'"
?
Thanks in advance.
Quick question:
let's say you have 2 different types of <button>
,
First one looks something like this: <button class="test">
Second looks like this: <button class="test" disabled="disabled">
.
Now, how can one achieve a selection of the disabled button without selecting the activated
button? Cause if you go by class, querySelector
would get both of them. Is there a way to implement some kind of logic into the selection made by querySelector
?
Something like this maybe -> "select button with class 'test' AND NOT attribute 'disabled'"
?
Thanks in advance.
Share Improve this question edited Sep 12, 2017 at 7:07 shishir 8493 gold badges11 silver badges27 bronze badges asked Sep 12, 2017 at 6:58 fweidemann14fweidemann14 1,9933 gold badges14 silver badges21 bronze badges1 Answer
Reset to default 7The same way you do it in any other selector. With the negation pseudo-class.
:not([disabled])