【发布时间】:2016-01-16 18:13:53
【问题描述】:
当用户通过平板设备访问网站时,我想禁用包含下拉菜单的链接,因此,当用户从平板电脑点击链接时:
-> 出现下拉菜单但链接被禁用,然后在第二次点击时链接有效。
我认为这可能已经解决了,但我还没有找到合适的,我正在使用来自here的代码
jQuery(document).ready(function ($) {
$("li.taphover > a").on('touchstart', function (e) {
'use strict'; //satisfy the code inspectors
var link = $(this); //preselect the link
if (link.hasClass('hover')) {
return true;
} else {
link.addClass('hover');
$('li.taphover > a').not(this).removeClass('hover');
e.preventDefault();
return false; //extra, and to make sure the function has consistent return points
}
});
});
但它会禁用链接,并且没有任何效果。
【问题讨论】:
-
$('li.taphover > a').not$(this).removeClass('hover'); -
把(这个)改成$(这个)
-
它不起作用,现在第一次点击链接到该站点。
标签: javascript jquery drop-down-menu tablet