Just adding return false;
at the end of the on("click touchstart")
event function can solve this problem.
$(this).on("click touchstart", function() {
// Do things
return false;
});
From the jQuery documentation on .on()
Returning
false
from an event handler will automatically callevent.stopPropagation()
andevent.preventDefault()
. Afalse
value can also be passed for the handler as a shorthand forfunction(){ return false; }
.