<li>
<a class="handle" href="abc.htm">TopLink</a>
<ul class="container">
<li>
<a href="xyz.htm">SubLink1</a>
</li>
</ul>
</li>
When click on TopLink (class=”handle”);
Question: how to write jQuery selector in such a way to select ul class=”container” whenever i click on TopLink
Something like;
$(this).(Get the next UL with classname=”container”)
If that will always be the structure of your HTML, you can simply use
next:If there might be elements between the link and the
ul, you could usesiblingsto get all elements that match the selector:Although that would also get preceding siblings. To just get following siblings, you could use
nextAll: