[英]jQuery click event not working in mobile Firefox
I have a navigation menu that shows and hides on mobile devices when an element is clicked. 我有一个导航菜单,当单击一个元素时,该菜单显示和隐藏在移动设备上。 It works everywhere except in Firefox on Samsung Galaxy 3. Here's the HTML:
除了Samsung Galaxy 3上的Firefox,它在所有地方都可以使用。以下是HTML:
<nav id="nav" role="navigation">
<ul>
<li>Menu Item 1</li>
<li>Menu Item 2</li>
Etc . .
</ul>
</nav>
<div id="nav-arrow">▼</div>
The element with the click event attached is "nav-arrow". 附加了click事件的元素是“ nav-arrow”。 Here is the jQuery:
这是jQuery:
$("#nav-arrow").click(function() {
if ($("#nav").is(":visible")) {
$("#nav").slideUp(800, function() {
$("#nav-arrow").html("▼");
});
} else {
$("#nav").slideDown(800, function() {
$("#nav-arrow").html("▲");
});
}
});
The container is has a property of display:none until the nav-arrow is clicked. 容器具有display:none属性,直到单击导航箭头。 Can anyone help me get this working on Mobile Firefox?
谁能帮助我在移动Firefox上运行该软件?
jQuery Mobile requires the "delegate" method: jQuery Mobile需要使用“委托”方法:
$(document).delegate('#nav-arrow', 'click', function () {
if ($("#nav").is(":visible"))
{
$("#nav").slideUp(800, function()
{
$("#nav-arrow").html("▼");
});
}
else
{
$("#nav").slideDown(800, function()
{
$("#nav-arrow").html("▲");
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.