Understanding of not() function in jQuery -
i not understand why still getting element <li class=".item-2">
red background. please take code , provide me tips.
<ul class="level-1"> <li class="item-i">i</li> <li class="item-ii">ii <ul class="level-2"> <li class="item-a">a</li> <li class="item-b">b <ul class="level-3"> <li class="item-1">1</li> <li class="item-2">2 .item-2</li> <li class="item-3">3</li> </ul> </li> <li class="item-c">c</li> </ul> </li> <li class="item-iii">iii</li> </ul> $("li.item-ii").find('li').not($(".item-2")).css("background-color", "red");
jsfiddle: http://jsfiddle.net/k3cqs/1/
find('li')
matches parent li well, excluding child doesn't matter when parent has red background.
you end this
<ul class="level-1"> <li class="item-i">i</li> <li class="item-ii">ii <ul class="level-2"> <li class="item-a" style="background-color: red;">a</li> <!-- below element red, , parent element --> <li class="item-b" style="background-color: red;">b <ul class="level-3"> <li class="item-1" style="background-color: red;">1</li> <!-- doesn't matter if isn't red --> <li class="item-2">2 .item-2</li> <li class="item-3" style="background-color: red;">3</li> </ul> </li> <li class="item-c" style="background-color: red;">c</li> </ul> </li> <li class="item-iii">iii</li> </ul>
.item-2
transparent, parents background showing.
Comments
Post a Comment