ipad - jquery touchstart not working on document -
a simple touchstart event work, if utilize syntax: http://jsfiddle.net/rwdu4hb9/
$(function(){ $('.test').on('touchstart', function(){ alert("clicked"); }); });
but if want add together event coming elements $(document).on(..)
here: http://jsfiddle.net/rwdu4hb9/1/
$(function(){ $(document).on('touchstart', '.test', function(){ alert("clicked"); }); });
the event not triggered. wrong call?
tested on ipad ios 8.0.2
out of curiosity, there reason avoiding using click
event instead of touchstart
? mobile browsers handle click
'touch' event. i've had problem in past touches vs. clicks on different devices (solved w/ modernizr)
at least, bind both events (click
, touchstart
), handle both mobile , desktop (updated fiddle - http://jsfiddle.net/srdkgl7o/)
$(function(){ $(document).on('touchstart click', '.test', function(e){ e.stoppropagation(); //stops 'ghost clicks' (double clicking) alert("clicked"); }); });
jquery ipad touchstart
No comments:
Post a Comment