event.preventDefault() on first click then remove

后端 未结 5 1471
余生分开走
余生分开走 2021-02-03 13:35

I have the default anchor disabled if it has a class subnav as shown in this fiddle.

I only want this disabled for the first click then I want the normal anchor function

5条回答
  •  花落未央
    2021-02-03 14:19

    This works well. The second click goes to the page...

    $(".smallNavigation > ul > li > a").click(function (e) {
    
        $("ul.sub-menu").hide();
        $("ul.sub-menu", $(this).parent("li")).show();
    
        e.preventDefault();
        $(this).unbind(e);
    
    }
    

提交回复
热议问题