How would I detect if an element had two parent uls so for example:
<ul>
<li>Link
<ul>
<li>Link
<ul>
<li class="this">Link</li>
</ul>
</li>
</ul>
</li>
</ul>
I’ve tried:
if ($('.this').parent('ul').parent('ul') == true)
but it doesn’t seem to work… Can anyone help? Thanks
There are 2 ways of doing this.
1) bottom up – starting from the element.
2) top-down
Performance wise, you should choose the first method, as it does not check every ul sub-tree, but only checks to see if the ‘.this’ element has 2 or more parent ul’s.