Reputation: 4920
I'm using JS+jQuery to create an interactive menu supposed to work both with pc and mobile devices. The menu is created on-the-fly, so I need to use .on()
.
I'm testing the mobile side with my iPad, my code is something like this:
jQuery(document).on('click touchstart','.button', function(){ /* Do... */ });
The click
event works fine on my PC, but the touchstart
doesn't do anything. Even leaving click
or touchstart
only it doesn't work on my iPad.
Upvotes: 0
Views: 8128
Reputation: 4920
I've definitely solved by putting touchstart
before click
in the .on()
method.
Upvotes: 1
Reputation: 55740
If this does not work ..
Try associating the event
after the element is added to the DOM
. Check if that helps..
// Button appended to your DOM on the fly
$('.button').on('touchstart', function(){
});
Upvotes: 0