[英]Can I close mobile menu on click for anchor links in Joomla project
我有这个小型 Joomla 项目,我需要移动菜单方面的帮助。 锚链接只是滚动但菜单不会关闭。 是否有任何脚本可以添加到 index.php 中?
这些是我的菜单类:
<div class="menu_mobile">
<ul class="nav menu mod-list">
<li class="items">
<ul class="nav-child unstyled" style="display: block;">
<li class="item-1"><a href="/anchor-link#link1">anchor link 1</a></li>
<li class="item-2"><a href="/anchor-link#link2">anchor link 2</a></li>
<li class="item-3"><a href="/anchor-link#link3">anchor link 3</a></li>
<li class="item-4"><a href="/anchor-link#link4">anchor link 4</a></li>
<li class="item-5"><a href="/anchor-link#link5">anchor link 5</a></li>
<li class="item-6"><a href="/anchor-link#link6">anchor link 6</a></li>
</ul>
</li>
</ul>
</div>
先感谢您。
这是我的工作解决方案:
//gives command on click to close the menu and go to the anchor link location
jQuery('.menu_mobile ul li a').click(function(){
jQuery("div.menu_mobile ul").css('display' , 'none');
jQuery("div.menu_mobile ul"). removeClass('nav menu mod-list');
//reloads the page without loosing the anchor link location
jQuery(".mobile-menu").click(function() { location.reload()
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.