I have 3 menus that use this .toggle and when I switch between menus it requires a second click for the menu to click on again. How do I make the second function stop if another menu is shown?

  $(".dd").toggle(function() {
      $("ul a", this).click(function(e) {
         e.stopPropagation();
      });
      $(".contextMenu").hide();
      $("ul", this).show();     
    }, 
    function() {
      $("ul", this).hide();
    }
  );

1 answer

0
points

I got this to work how I wanted it. Thanks to this thread http://stackoverflow.com/questions/244392/jquery-toggle-state

$(".dd").click(function() {

$("ul", ".dd").not(this).hide();
$("ul", this).toggle();

}); $(".wrapper").click(function() {

$("ul", ".dd").hide();

});

Answered over 8 years ago by Stephen Way