我正在尝试使ontouchstart适用于Windows平板电脑。如果检测到,它将禁用我的链接的顶层,从而使click事件允许菜单保持打开状态(而不是悬停效果)。以下代码可在其他触摸设备上使用,因此我不确定是否还需要做其他事情? $topLink.on('click', function (e) { $dropDown.removeClass('child'); $dropDown.not($(this).next('.dropdown')).removeClass('open'); $topLink.not($(this)).removeClass('active-link'); $(this).next('.dropdown').toggleClass('open'); $(this).toggleClass('active-link'); if (("ontouchstart" in document.documentElement) || ($window.width() < 1120)) { // disable top level links for touch e.preventDefault(); e.stopPropagation(); } });
添加回答
举报
0/150
提交
取消