onClick listener for touch screens and tablets
I have a bunch of click listeners in my jquery and was wondering what I need to do to get them to work on mobile devices and touch screens? So if my code is...
$(el).bind('click', function () {
//my event function
});
d开发者_开发问答o I need to do like...
$(el).bind('click, touch', function () {
//my event function
});
Use jQuery mobile. It has events exactly for touchscreens and tablets: tap, taphold
etc
click
is perfectly handled on touch devices as a tap
, so you don't need to do anything.
The touch device specific events are swipe
and such.
If you get click events on regular devices you also get click events on mobile devices when "clicking" them on the touch screen.
You only need special events if you want to support advanced touchscreen/multitouch-related features.
精彩评论