如何防止菜单点击功能和主动双击只 [英] How to prevent menu from click function and active double click only

查看:74
本文介绍了如何防止菜单点击功能和主动双击只的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试一个网站,并且希望并注意到菜单中存在一个问题:
我有一个名为About的项目,它有它的子项......问题是关于它也是一个链接。因此,在移动设备上,如果点击关于下方的点击,则会显示孩子,但在尝试点击任何列表项目之前,网站会转到关于页面。
嗯,我认为这都是因为我使用悬停和焦点。



我怎样才能点击一个菜单项有儿童显示其项目和当我第一次点击时阻止它进入页面?
在这里我的小提琴: https://jsfiddle.net/Wosley_Alarico/mvn7ayun/1/



我在想,首先我必须阻止点击功能:

  $(document).ready(function(){
$(li.menu-item-has-children).click(function(e){
e.preventDefault ();

});
});

希望我有所帮助,因为英语不是我的第一语言
<解决方案这里是解决方案:)不要在很多地方使用这个代码)))

解决方案

`https:// jsfiddle.net / mvn7ayun / 21 /`


I am testing a website and would like and noticed a problem in the menu: I have an item called About, that has it children...problem is that about is a link too. So, on mobile, If a click under About,the children will be displayed,but before I try to click on any list item,the sites goes to the About page. Well I assume that it is all because I am using hover and focus.

How can I click on a menu item that has children to display its item and prevent it from going to it's page when I click for the first time? Here my fiddle: https://jsfiddle.net/Wosley_Alarico/mvn7ayun/1/

I am thinking that first of all I must prevent the click function perhaps:

$(document).ready(function (){            
   $( "li.menu-item-has-children" ).click(function( e ) {
      e.preventDefault();

   });
});

Hope I made some sense since English is not my first language

解决方案

Here is Solution :) Do not use this code in many places)))

`https://jsfiddle.net/mvn7ayun/21/`

这篇关于如何防止菜单点击功能和主动双击只的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆