如何防止第一次单击时的链接操作,并允许仅使用jquery进行第二次单击 [英] how to prevent a link action on a first click and allowing second click only using jquery
问题描述
我正在努力寻找类似于我之前已经发布的一个问题的解决方案,该解决方案没有准确的解决方案。
I am struggling to find a solution similar to a question that I have already posted previously which had not accurate solution.
如果你在手机上查看这个网站设备: http://www.adfinity.co.za/business-partners/。如果您第一次在关于我们菜单项下单击时会看到它,它将显示子项...并且只有当您第二次单击时,它才会显示关于我们页面。
我寻找其他一些问题,但他们并没有真正做到这一点。
If you look at this site on your mobile device: http://www.adfinity.co.za/business-partners/ .If you will see that when you click under About Us Menu Item for the first time, it will show the sub-items...and only when you click for the second time it will take you to the About Us page. I looked for some other questions but they don't really do this.
我几天前发布了一个类似的问题没有最终答案:
如何阻止菜单点击功能和仅活动双击
I posted a similar question a few days ago which had no final answer: How to prevent menu from click function and active double click only
请帮我为我的网站做这件事。
Please help me to do that for my site.
现在我试过这个:
$(document).ready(function (){
$("ul#primary-menu > li.menu-item-has-children").one("click", function(e) {
e.preventDefault();
$(this).text("Click again to open");
});
});
当我在实际的手机上测试时,不得不双击该项目,只有那个子-items下降。
When I tested on the actual mobile, had to to double click on the item, only then the sub-items dropped down.
推荐答案
您的代码应该可以工作,只要确保也返回false并检查浏览器控制台以查看如果jQuery中有任何错误:
Your code should work, Just make sure to return false too and also check your browser console to see if there are any errors in jQuery:
$(document).ready(function (){
$("ul#primary > li.menu-item-has-children").one("click", function(e) {
e.preventDefault();
$(this).text("Click again to open");
return false;
});
});
这篇关于如何防止第一次单击时的链接操作,并允许仅使用jquery进行第二次单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!