简体   繁体   English

iPad上的jQuery单击事件无法正常工作

[英]jQuery click event on iPad not working properly

The click event should work fine: 点击事件应该可以正常运行:

  subMenu = $(".sub-menu")
  //....
  subMenu.show()
  $("a.mobile").click (e) ->
      menuContainer.toggle()
      e.preventDefault()

This should toggle the menu on click/tap. 这应该在单击/点击上切换菜单。 The weird thing is that it does it just fine for the first open and close. 奇怪的是,它在第​​一次打开和关闭时都很好。 Starting with the second time, to open, I have to click "a.mobile" twice. 从第二次开始,要打开,我必须单击两次“ a.mobile”。 I've tried bind, and a bunch of other options. 我已经尝试过bind,还有很多其他选择。 The CSS is actually displaying the link as it were hovered when it's not double-tapped. CSS实际显示的是未双击时悬停的链接。

I'm not 100% sure about .click() function, however i use .on('click') for handle events on my application and it works everywhere (including IPads ). 我不确定.click()函数,但是我使用.on('click')处理应用程序上的事件,并且它在任何地方(包括IPads )都可以使用。 Nevertheless as suggested by the comments, perhaps there is something elsewhere preventing the click to work as you expect. 不过,正如评论所建议的那样,也许其他地方阻止了点击按预期工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM