Using touchstart or touchhend is not a good solution, because if you scroll the page, the device detects it as a tap or tap. Thus, the best way to simultaneously detect a click and click event is to simply detect touch events that do not move the screen (scrolling). Therefore, for this, simply add this code to your application:
$(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){ //here you can write the function or codes you wanna execute on tap } });
I tested it and it works great for me on iPad and iPhone. It detects taps and can easily distinguish between touch and touch.
Iman Sedighi Jul 24 '16 at 8:58 2016-07-24 08:58
source share