Close a menu with an anywhere click

后端 未结 5 2002
无人共我
无人共我 2021-01-06 17:18

As you guys can see, I have a drop down menu.

I have a lot of columns, each one has an option to open the menu.

$(\".optionCont\").live(\"click\", fu         


        
5条回答
  •  青春惊慌失措
    2021-01-06 17:50

    $(".optionCont").click(function(e){
        $(".dropMenuCont").slideUp();
        if($(this).next().css("display") == "none"){
            $(this).next().slideDown();
        }else{
            $(this).next().slideUp();
        }
        e.preventDefault();
        e.stopPropagation();
        return false;
    });
    
    $(document).click(function() {
         $(".dropMenuCont").slideUp();
    });
    

    Here is the JSFiddle

提交回复
热议问题