Translating touch events from Javascript to jQuery
133,291
Solution 1
jQuery 'fixes up' events to account for browser differences. When it does so, you can always access the 'native' event with event.originalEvent
(see the Special Properties subheading on this page).
Solution 2
$(window).on("touchstart", function(ev) {
var e = ev.originalEvent;
console.log(e.touches);
});
I know it been asked a long time ago, but I thought a concrete example might help.
Author by
K2xL
python, go, php, node/javascript, ruby, java, and general web development is what i do
Updated on November 22, 2020Comments
-
K2xL over 3 years
I am using
window.addEventListener("touchstart", function(ev){ console.log(ev.touches); // good });
How can I translate this to jQuery? I've tried:
$(window).bind("touchstart",function(ev){ console.log(ev.touches); // says ev.touches is undefined }
Any ideas?
-
Johannes Pille almost 8 yearsThanks for taking the notion of a "concrete example" being beneficial seriously.