html - Css selector .a.b how do i exclude it from selecting a.b.c? -
i have inherited markup similar html below.
<div class="a b">how_can_i_select_ab_only</div> <div class="a b disabled">how_can_i_select_ab_and_disabled_only</div>
i want select both elements individually.
css selector .a.b selects both divs
<div class="a b">how_can_i_select_ab_only</div>
<div class="a b disabled">how_can_i_select_ab_and_disabled_only</div>
what selector select class a.b.disabled , class a.b ?
three ways how it:
the first one, set styles .a.b
, them remove them (override) .a.b.disabled
.
.a.b {color: red;} .a.b.disabled {color: grey}
https://jsfiddle.net/p84s61gp/
the second way, use attr
selector.
[class='a b'] {color: red}
https://jsfiddle.net/p84s61gp/1/
next, can use :not
selector, support since ie9.
.a.b:not(.disabled) {color: red}
Comments
Post a Comment