Why is the event object different coming from jquery bind vs. addEventListener

Posted by yodaisgreen on Stack Overflow See other posts from Stack Overflow or by yodaisgreen
Published on 2010-05-19T06:04:19Z Indexed on 2010/05/19 6:10 UTC
Read the original article Hit count: 331

Why is it when I use the jQuery bind the event object I get back is different from the event object I get back using addEventListener?

The event object resulting from this jQuery bind does not have the targetTouches array (among other things) but the event from the addEventListener does. Is it me or is something not right here?

$(document).ready (function () {
    $("#test").bind("touchmove", function (event) {
        console.log(event.targetTouches[0].pageX);
        // targetTouches is undefined
    });
});

vs.

$(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);
});

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about javascript-events