Is it possible to hide all elements of an class which are not the same as the class. i tried the code below but its not working.
li.show *>:not(.show) {
display: none !important;
}
Is it possible to hide all elements of an class which are not the same as the class. i tried the code below but its not working.
li.show *>:not(.show) {
display: none !important;
}
do you want like this.?
ul.hello>li:not(.hello){
display : block;
border:1px solid grey;
}
ul.hello>li.hello{
display : block;
border:1px solid red;
}
<ul class="hello">
<li>with multiple classes.</li>
<li class="hello"> and</li>
<li class="aetw"> and</li>
<li class="hello"> I want to hide every </li>
<li class="sdf"> and</li>
<li class="hello"> I want to hide every </li>
</ul>
here is jsfiddle Demo
The problem in your fiddle is that you write <div>
instead of </div>
everywhere, which causes all the content to end up in the first div in the li.
Solution: correct all the errors, then it will work as expected.
.show1 :not(.show1),
.show2 :not(.show2) {
display: none
}
<ul>
<li class="show1">
<div class="show1">show1</div>
<div class="hide">hide</div>
<div class="hide">hide</div>
<div class="hide">hide</div>
</li>
<li class="show2">
<div class="hide">hide</div>
<div class="show2">show2</div>
<div class="hide">hide</div>
<div class="hide">hide</div>
</li>
</ul>
with multiple classes.- and
- and
-
I want to hide every
- which is not
– Jörn Matthes Nov 06 '15 at 09:28