如何通过单击而不是悬停来打开 Superfish jQuery 菜单?
我在网上快速浏览了一下 Joel Birch 实现的 Superfish 菜单,该菜单适用于单击,而不是悬停。
在 Github 上找到了 Karl Swedberg 的这个链接,看起来像票。
https://gist.github.com/917446
它就像一个魅力,直到我点击一个活动的点链接,此时菜单关闭,并且似乎返回 false。
我怎样才能让它导航到实际的链接目的地?
I've had a quick browse around the web for an implementation of Superfish menu by Joel Birch that works on onclick, rather than hover.
Found this link by Karl Swedberg at Github, which looks like the ticket.
https://gist.github.com/917446
It works like a charm, right up to the point where I click on an active link, at that point the menu closes, and appears to return false.
How can I get it to navigate to the actual link destination?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Karl 在 GitHub 上发布了一个快速更新来帮助我解决问题:https://gist.github.com/652684对我来说不太管用。
从下面的链接获取我的工作代码。
http://www.nilinks.com/home-owner/wp- content/themes/acheson/js/superfish.js
已更新..以防链接失效..
Karl posted a quick update to help me out on GitHub.. here: https://gist.github.com/652684 that didn't quite work for me.
Grab my working code from the below link.
http://www.nilinks.com/home-owner/wp-content/themes/acheson/js/superfish.js
updated.. just incase that link ever dies..
更改此行(第 21 行,函数上方):
为此:
用于单击菜单的完整 superfish 代码:
Changing this line (line 21, over function):
To this:
Full superfish code for clicking the menu:
如果有人在使用 drupal 中的 superfish 模块时来这里寻找这个答案(我正在使用 drupal 8 模块)。我根本没有修改superfish库。我在我的 js 文件中做了以下操作,它似乎工作正常(在 chrome 和 firefox 上测试)。
下面的代码禁用鼠标悬停时下拉菜单。当您单击父菜单项时,菜单会下拉并且实际上不会转到父级 href。
我不使用 superfish 作为我的移动菜单,因此我没有在移动设备上测试上述内容,但我想您需要做一些工作才能按照您想要的方式获得它。
编辑
由于某种原因,以上内容不适用于 Safari。以下适用于 chrome、safari 和 firefox
If anyone comes here looking for this answer while using the superfish module in drupal (I am using the drupal 8 module). I didn't modify the superfish library at all. I did the following is in my js file and it seems to be working fine (tested on chrome and firefox).
The below code disables the menu dropping down on mouseover. When you click the parent menu item the menu drops down and does not actually go to the parent href.
I dont use superfish as my mobile menu so I have not tested the above on mobile, but I'd imagine you'll need to do some work to get it how you want it.
EDIT
The above wasn't working on safari for some reason. The below works on chrome, safari and firefox