2014-09-30 48 views
0

對於我目前正在使用的網站,使用Jansy Off畫布菜單(found here)。我將菜單滑出,如果再次單擊漢堡菜單,它會滑回。但是,如果用戶還點擊了其中一個鏈接,我希望它可以放棄。現在它只剩下了。點擊鏈接後滑出畫布菜單

我試圖用這個代碼:

$(".navbar-toggle").unbind().on("click", function() { 
     console.log("toggle"); 
     $("#myNavmenu a").offcanvas("hide") 
    }); 

但只有在點擊菜單漢堡得到射擊。

這就是漢堡菜單看起來像我的HTML:

<!-- burger menu --> 
<div class="container"> 
    <div class="row"> 
     <div id="burgerWrapper"> 
      <nav id="myNavmenu" class="navmenu navmenu-default navmenu-fixed-left offcanvas" role="navigation"> 
       <ul class="nav navmenu-nav"> 
        <!-- Hidden li included to remove active class from about link when scrolled up past about section --> 
        <li class="hidden"><a class="page-scroll" href="#page-top"></a></li> 
        <li><a href="#criminalLaw" class="page-scroll">CRIMINAL LAW</a></li> 
        <li><a href="#criminalLocalCourt" class="page-scroll">LOCAL COURT MATTERS</a></li> 
        <li><a href="#criminalMentalHealth" class="page-scroll">SECTION 32 APPLICATIONS</a></li> 
        <li><a href="#criminalConviction" class="page-scroll">CONVICTION AND SEVERITY APPEALS</a></li> 
        <li><a href="#criminalPenalties" class="page-scroll">INDICTABLE MATTERS</a></li> 
        <li><a href="#criminalFee" class="page-scroll">FEE ARRANGEMENTS</a></li> 
       </ul> 
      </nav> 
      <div class="navbar navbar-default navbar-fixed-top" data-spy="affix" data-offset-top="200"> 
       <button type="button" class="navbar-toggle" data-toggle="offcanvas" data-target="#myNavmenu" data-canvas="body"> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
      </div> 
     </div> 
    </div> 
</div> 
<!-- end burger menu --> 

回答

0

我相信下面的代碼將解決您的問題。

$(".nav li a").click(function(){ 
 
    
 
    $('#myNavmenu').offcanvas("hide"); 
 

 
});