Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Mobile Touch Events

jQuery Mobile Touch Events


Touch events are triggered when a user touches the screen (page).

lamp Touch events can also be applied to desktop computers:Click or swipe the mouse!

jQuery Mobile Tap

The tap event is triggered when a user taps an element.

In the following example: when tapping

an element, hide the current

element:

Example

$("p").on("tap",function(){

  $(this).hide();

});

Try it »


jQuery Mobile Taphold (Long Press)

The taphold (long press) event is triggered after tapping and holding (about one second)

Example

$("p").on("taphold",function(){

  $(this).hide();

});

Try it »


jQuery Mobile Swipe

The swipe event is triggered when a user drags horizontally more than 30px, or vertically less than 20px, within one second:

Example

$("p").on("swipe",function(){

  $("span").text("Swipe detected!");

});

Try it »


jQuery Mobile Swipe Left

The swipeleft event is triggered when a user drags an element more than 30px to the left:

Example

$("p").on("swipeleft",function(){

  alert("Swipe left!");

});

Try it »


jQuery Mobile Swipe Right

The swiperight event is triggered when a user drags an element more than 30px to the right:

Example

$("p").on("swiperight",function(){

  alert("Swipe right!");

});

Try it »