i'm working with wordpress+jQuery - there's a navigationscript (it's an UL) with several levels like this:
<ul>
<li>level 1 - item1</li>
<li>level 1 - item2
<ul>
<li>level 2 - item1</li>
<li class=current_page_item>level 2 - item2</li>
</ul>
</li>
<li>level 1 - item3</li>
</ul>
wordpress is applying a css-class called current_page_item to the current LI. my question: when selecting that LI - how can i find out it's level in the UL? (in my case: level 2)
By counting its parents:
$('.current_page_item').parents('ul').length;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With