爲什麼當我使用jQuery綁定事件對象我回來的事件對象與使用addEventListener返回的對象不同?爲什麼事件對象不同來自jquery綁定與addEventListener
由此jQuery綁定產生的事件對象沒有targetTouches數組(除其他外),但來自addEventListener的事件沒有。是我還是不是在這裏?
$(document).ready (function() {
$("#test").bind("touchmove", function (event) {
console.log(event.targetTouches[0].pageX);
// targetTouches is undefined
});
});
與
$(document).ready (function() {
var foo = document.querySelectorAll('#test')
foo[0].addEventListener('touchmove', function (event) {
console.log(event.targetTouches[0].pageX);
// returns the correct values
}, false);
});
你能發表涉及創建targetTouches變量的代碼嗎? – ground5hark 2010-05-19 06:11:08
@bobthabuilda:'targetTouches'是'touch'事件的一個屬性,如果我沒有記錯的話,只有在Safari/WebKit(在iPhone應用上很常見)時纔可用。 – CMS 2010-05-19 06:26:46