Accordion Menu issues
<p>I have created a simple accordion menu.My problem is when i click "Folder1" it expands but when i click it back again it should collapse .. i'm stuck with that and not able to proceed any help..</p>

<p>JsFiddle - <a href="http://jsfiddle.net/nY2t7/" rel="nofollow">http://jsfiddle.net/nY2t7/</a></p>

<pre><code>$(document).ready(function() {


    $('#content &gt;li').each(function(i){

        hideElements($(this));
    });

    $('#content').click(function(event) {

        $x = $(event.target);

        //check if the element is the root node if so then hide all other li's and reveal the current one
        if($x.parent().is('ul#content')) {

            if($x.is(':visible')) {     //check if its already expanded .. if so then collapse and return
                $x.find('ul &gt;li').slideUp(300 , function() {
                    **//return;** does not work

                });
            }

            $('#content ul&gt;li').each(function(i){                   
                    collapseElements($(this));
            });
        }


        if($x.is('li'))
            $x.find('ul:first &gt; li').slideToggle(300);  



    });


    function collapseElements(el) {
        if(el.is(':visible')) {
            el.slideUp(300);
        }

    }

    function hideElements(elem) {
        elem.find('ul &gt;li').hide(); 

        //$($e &gt;li).hide(); 
    }
});
</code></pre>
