jQuery on click not working on iPhone (touch devices)

Viewed 20233

Can anyone please explain to me why this is working in the browser but not on mobile devices like Apple's iPhone. On iPhone, I never get the hello from the alert. Why?

<div class="close">
  Click here
</div>

JS:

$(document).on('click', '.close', function() {
  alert('hello');
});

Example here: https://jsfiddle.net/27ezjrqr/5/

4 Answers

I used the touchstart event with the click , it did the job for me

 $(document).on("click touchstart tap", "#button_X", function (){
//your code here      
 });
Related