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

时间:2021-11-26 21:27:06

The click event should work fine:

click事件应该可以正常工作:

  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. I've tried bind, and a bunch of other options. The CSS is actually displaying the link as it were hovered when it's not double-tapped.

这应该在点击/点击时切换菜单。奇怪的是它在第一次打开和关闭时做得很好。从第二次开始,要打开,我必须点击“a.mobile”两次。我尝试过bind,以及其他一些选项。 CSS实际上是显示链接,因为它没有被双击。

1 个解决方案

#1


1  

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). Nevertheless as suggested by the comments, perhaps there is something elsewhere preventing the click to work as you expect.

我不是100%肯定.click()函数,但我使用.on('click')处理我的应用程序上的句柄事件,它可以在任何地方工作(包括IPads)。尽管如此,根据评论的建议,也许其他地方会阻止点击按预期工作。

#1


1  

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). Nevertheless as suggested by the comments, perhaps there is something elsewhere preventing the click to work as you expect.

我不是100%肯定.click()函数,但我使用.on('click')处理我的应用程序上的句柄事件,它可以在任何地方工作(包括IPads)。尽管如此,根据评论的建议,也许其他地方会阻止点击按预期工作。