Home › Forums › JavaScript › Touch device ghost click triggers on different element › Reply To: Touch device ghost click triggers on different element
March 18, 2017 at 11:39 am
#252907
Member
I’ve heard that this solution from Stackoverflow takes care of the ghost click:
$(document).on('touchstart click', '.myBtn', function(event){
if(event.handled === false) return
event.stopPropagation();
event.preventDefault();
event.handled = true;
// Do your magic here
});
Additionally, you might want to consider using pointer events… jQuery’s polyfill PEP is useful in this case. Check out the Why pointer events section in the readme!