[英]Multiple Dropdown Menus
I am looking to add two different "navigation" sections to a page on mobile. 我希望将两个不同的“导航”部分添加到移动设备页面上。 Here is the jQuery pull to make the dropdown work.
这是使下拉菜单起作用的jQuery pull。 However, when I add in a second section of markup for the second dropdown, the one menu button opens BOTH menus.
但是,当我在第二个下拉菜单中添加标记的第二部分时,一个菜单按钮将同时打开两个菜单。 Is it possible to use more than one?
可以使用多个吗? Or what am I missing to make it open each one separately?
还是我缺少将其分别打开的功能?
<script>
jQuery(function() {
var pull = jQuery('#pull');
menu = jQuery('nav ul');
menuHeight = menu.height();
jQuery(pull).on('click', function(e) {
e.preventDefault();
menu.slideToggle();
});
});
jQuery(window).resize(function(){
var w = jQuery(window).width();
if(w > 320 && menu.is(':hidden')) {
menu.removeAttr('style');
}
});
</script>
You need to change the menu
and pull
variable values. 您需要更改
menu
并pull
变量值。
Also, add a var before the variables as so, so the variables don't become global: 同样,在变量之前添加var,这样变量就不会成为全局变量:
var pull = jQuery('#pull');
var menu = jQuery('nav ul');
var menuHeight = menu.height();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.