我使用 jQuery 来检测 DOM 上的点击 - 或者让我们检测每次点击。
$(document).click(function(){
alert("Click :-)");
});
除了 iPad/iPhone 版 Safari 之外,该功能在所有浏览器中都表现良好。我还尝试在 html 或 body 元素上应用该事件 - 没办法。如何检测iPad/iPhone上的普通点击?
此致,
吉姆
正如我发现的http://www.danwellman.co.uk/fixing-jquery-click-events-for-the-ipad/ http://www.danwellman.co.uk/fixing-jquery-click-events-for-the-ipad/您可以测试用户代理并根据平台使用 touchstart 或 click
var ua = navigator.userAgent,
event = (ua.match(/iPad/i)) ? "touchstart" : "click";
$(document).on(event, function (ev) {
...
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)