Reputation: 42394
I am trying like this and its not working in iphone
$(document).bind('touchstart',function(){
alert('hello');
});
but its working like this
document.addEventListener('touchstart', function(){
alert('hello');
}, false);
how to get touchstart event working with jquery?
Its working with
$(document).on('touchstart', function(e){
//e.preventDefault();
var touch = e.touches[0] || e.changedTouches[0];
});
but getting error e.touches is not an object
Upvotes: 9
Views: 18749
Reputation: 22933
To get the touches property you can use e.originalEvent:
$(document).on('touchstart', function(e){
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
});
Upvotes: 12