I have something like this :
- first level 1
- 2nd level 1
- 3rd level
- 3rd level 2
- 2nd level 2
- 2nd level 1
- first level 2
I want to addClass to all sibling li elements that follow the li elements containing anchor tag .
I tried doing this
$(li>a).next().addClass('makebold');
the $(li>a) does select the first level 1 li element and then according to next() which selects the immediately following sibling of the selected/matched element ,the element which should get BOLD by addition of class has to be first level 2 .
but the li elements-of 2nd and 3rd level are getting bold . I am wondering why ?
here is my html code for ul list
<ul>
<li><a href="">first level 1</a>
<ul>
<li>2nd level 1
<ul>
<li><a href="">3rd level</a></li>
<li>3rd level 2</li>
</ul>
</li>
<li>2nd level 2</li>
</ul>
</li>
<li>first level 2</li>
</ul>