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} 

https://jsfiddle.net/p84s61gp/2/


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -