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
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];
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With