Programming Tips - jQuery: detect touch events

Date: 2018nov15 Language: javaScript Library: jQuery Q. jQuery: detect touch events A. Regular jQuery has no built in support. jQuery Mobile has it - worth considering if you want touch support.
// You probably don't want touches when the user is scrolling in their // browser. This takes care of that. var detectTap = false; $(document).on('touchstart', function() { detectTap = true; // Detects all touch events }); $(document).on('touchmove', function() { detectTap = false; // Excludes the scroll events from touch events }); $(document).on('click touchend', function(event) { if (event.type == 'click') detectTap = true; // Detects click events if (detectTap){ // Its a tap! Put your tap code here. } });
I got this stackoverflow - NOT the highest rated answer - but the best in my opinion https://stackoverflow.com/questions/4755505/how-to-recognize-touch-events-using-jquery-in-safari-for-ipad-is-it-possible