为了账号安全,请及时绑定邮箱和手机立即绑定

ontouchstart在Windows 8 Tablet上不起作用

ontouchstart在Windows 8 Tablet上不起作用

互换的青春 2021-04-09 13:14:00
我正在尝试使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();        }    });
查看完整描述

1 回答

?
倚天杖

TA贡献1828条经验 获得超3个赞

IE / Edge没有TouchEvents(至少默认情况下未启用),它具有PointerEvents


查看完整回答
反对 回复 2021-04-22
  • 1 回答
  • 0 关注
  • 198 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信