繁体   English   中英

HTML5 部分 touchstart touchmove touchend iOS

[英]HTML5 section touchstart touchmove touchend iOS

请有人帮我解决这个问题:

touchStart = function (evt) {
    evt.preventDefault();
    $(this).addClass("touched");
};

touchEnd = function (evt) {
    evt.preventDefault();
    $(this).removeClass("touched");
};

s.ontouchstart = touchStart;
s.ontouchend = touchEnd;
s.ontouchmove = touchEnd;

我有一个由 JavaScript 动态生成的 section 元素(ul > li > section)。 当我将 touchstart-touchmove-touchend 事件侦听器绑定到此部分元素时,它适用于 Android,但不适用于 iPad/iPod/iPhone。

我尝试使用onclick="void(0)"属性生成它,它使 section 元素像可点击元素一样“交互”,但它仍然什么都不做。

它可以在 Android 上以各种方式运行,但这种蔬菜现在对我来说似乎有点消耗无用...... =)

提前致谢! =)

没关系,用 jQuery 搞定的。 这样它到处运行。

$(s).bind("touchstart mousedown", function (e) {
    console.log(e.type); // to get the name of the event
}).bind("touchmove mousemove", function (e) {
    // ...
}).bind("touchend mouseup", function (e) {
    // ...
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM