Jquery touchstart event not working on iphone

I try like this and its not working on iphone

$(document).bind('touchstart',function(){ alert('hello'); }); 

but it works like this:

 document.addEventListener('touchstart', function(){ alert('hello'); }, false); 

how to get touchstart event working with jquery?

Work with the

 $(document).on('touchstart', function(e){ //e.preventDefault(); var touch = e.touches[0] || e.changedTouches[0]; }); 

but getting the e.touches error is not an object

+8
jquery
source share
1 answer

To get the touch property, you can use e.originalEvent:

 $(document).on('touchstart', function(e){ var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0]; }); 
+11
source share

All Articles