jquery child selector problems
        Posted  
        
            by codedude
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by codedude
        
        
        
        Published on 2010-04-09T17:08:20Z
        Indexed on 
            2010/04/09
            17:13 UTC
        
        
        Read the original article
        Hit count: 375
        
jQuery
|jquery-selectors
I have a basic website nav layout that looks like this:
    <li class="folder parent_folder">
<a href="#">Some Folder</a>
<ul class="submenu">
    <li class="file"><a href="#">An awesome file</a></li>
    <li class="file"><a href="#">An awesome file</a></li>
    <li class="file"><a href="#">An awesome file</a></li>
    <li class="file"><a href="#">An awesome file</a></li>
    <li class="file"><a href="#">An awesome file</a></li>
    <li class="file"><a href="#">An awesome file</a></li>
</ul>
I have several of these throughout the site's page. Using jquery, I'm trying to make it so that when you click "li.parent_folder" "ul.submenu" disappears and then reappears when you click "li.parent_folder" again. I can get it to do this but I have a problem. When I click on the "li.parent_folder" all the "ul.submenu" disapear instead of just the one that is the child of it.
What would be the correct jquery code to accomplish this? (Oh, I'm using jquery ui also in this project
What I have right now is this:
$('li.parent_folder').click(function() { $('li.parent_folder > ul.submenu').hide(); });
© Stack Overflow or respective owner