 <p>If I understand what you're trying to do... you can do something like this:</p> <pre><code>// For my benefit, hide all lists except the root items $('ul, li', $('#lesson-sidebar ul li')).hide(); // Show active parents and their siblings $('li a.active').parents('ul, li').each(function() { $(this).siblings().andSelf().show(); }); // Show the active item and its siblings $('li a.active').siblings().andSelf().show(); </code></pre> <p>The <a href="http://docs.jquery.com/Traversing/parents" rel="nofollow noreferrer">parents()</a> and <a href="http://docs.jquery.com/Traversing/siblings#expr" rel="nofollow noreferrer">siblings()</a> methods are both great for this kind of thing.</p> <p>Edit: There was a bug before where it wasn't showing parent siblings. Try this new version.</p> <p>Edit 2: Now it works with class="active" on the anchor instead of the list item.</p>