我在wordpress中使用wp-bootstrap-navwalker并尝试设计主菜单,方法是点击菜单中的选项,当它下降时,在导航到子链接时保持打开状态。但是,当我点击子链接时,菜单的下拉部分关闭。如何在导航到另一个页面后防止它消失/关闭,因为我想在新页面中保持下拉部分打开。我想尝试像这个网站一样的菜单: http://www.serneke.se/
这是我的代码:
<nav class="navbar navbar-fixed-top navbar-default">
<div class="container">
<div class="navbar-header" >
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<?php
wp_nav_menu( array(
'menu' => 'primary',
'theme_location' => 'primary',
'depth' => 2,
'container_id' => 'bs-example-navbar-collapse-1',
'menu_class' => 'nav navbar-nav pull-right',
'fallback_cb' => `enter code here`'wp_bootstrap_navwalker::fallback',
'walker' => new wp_bootstrap_navwalker())
);
?>
</div><!-- /.nav-collapse -->
========================================================
(function($){
$(document).ready(function(){
$('.dropdown').on('show.bs.dropdown', function(){
$(".dropdown-toggle").removeAttr('data-toggle');
});
});
})(jQuery);
=============================================== ========== 我相信我的代码会禁用下拉菜单,如果再次点击它就会关闭,当我点击子链接时,仍会关闭下拉菜单。请指导我