Fix When jQuery Click Event Is Not Working On Touch Devices

You might have come across situations when the jQuery click occasion listener works high-quality on laptop but it doesn’t fireplace on mobiles, pills and different touch gadgetsthis could show up while the occasion isn’t always connected to an anchor tag but to a few different element, like a div. there is a totally simple strategy to fix this trouble.
That is how your original looks like in maximum instances.



$(document).ready(function(){
$("div.clickable").click(function(){
alert('Click');
});
});

The correct code is below:

$(document).ready(function(){
$("div.clickable").on('click', function () {
alert('Click');
});
});

All you have to do is replace this part .click(function with this .on(‘click’, function

I hope this simple trick helped you make your click events work on mobile and other touch devices.

Please follow and like us:



Leave a Comment

Your email address will not be published. Required fields are marked *