How to make superfish dropdown menu responsive?

前端 未结 5 1204
感动是毒
感动是毒 2020-12-01 04:59

I am using superfish dropdown menu with skelton framework. I wanted it to work on mobiles as well. By default its showing the dropdown items but it hover over the items belo

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-01 05:37

    This is what I use:

        isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
    
    $(".menu a").click(function(event){
            if($(this).parents("ul").length == 1 && !$(this).hasClass("lastClick") && isMobile)
                event.preventDefault();     
    
            $(".menu a").removeClass("lastClick");
            $(this).addClass("lastClick");
        });
    

    Replace ".menu a" with your navigation links and this snippet will navigate the user to the clicked site after the second click and the first click will only show him the subpages.

提交回复
热议问题