window.addEventListener("touchstart", function(ev){
console.log(ev.touches); // good
});
如何翻译这jQuery的?我试过了:
$(window).bind("touchstart",function(ev){
console.log(ev.touches); // says ev.touches is undefined
}
有什么想法吗?
window.addEventListener("touchstart", function(ev){
console.log(ev.touches); // good
});
如何翻译这jQuery的?我试过了:
$(window).bind("touchstart",function(ev){
console.log(ev.touches); // says ev.touches is undefined
}
有什么想法吗?
jQuery'修复'事件以解决浏览器差异。在此情况下,您始终可以使用event.originalEvent
访问“原生”事件(请参阅this page上的特殊属性子标题)。
$(window).on("touchstart", function(ev) {
var e = ev.originalEvent;
console.log(e.touches);
});
我知道它很久以前就被问过了,但我认为一个具体的例子可能会有所帮助。
感谢您认真对待“具体示例”这一概念。 –
感谢,相对较新的网站。刚回去就批准了很好的答案。 – K2xL
不用担心。很高兴你知道了:) –
一个简单的jQuery库:https://github.com/Tundra-Interactive/swipe.jquery.js –