How can i fix this jquery script for submenu?

Posted by Giulio Bambini on Stack Overflow See other posts from Stack Overflow or by Giulio Bambini
Published on 2013-11-12T03:34:47Z Indexed on 2013/11/12 3:54 UTC
Read the original article Hit count: 220

Filed under:
|
|

This is the code and this is the result: www.studionews24.com you can see test the menu by clicking inside.

$(document).ready(function () {
    var $links = $('#menu-menu-1 .menu-item a').click(function () {



        var submenu = $(this).next();
        $subs.not(submenu).hide()
        submenu.toggle(500);
        $("#menu-2").slideToggle(300);
    });
    var $subs = $links.next(); });

The problem is that if I click on the menu it appears the submenu, but if I don't close the submenu that I have open and I open another voice in the menu it doesn't work properly.

If I click another .menu-item a when #menu-2 is open what happens? The script close and open another submenu correctly but my #menu-2 close only close. And then if I close .menu-item a so... #menu-2 open. How can I do to fix?

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery