jQuery Mobile swipeEvent

jQuery Mobile 事件jQuery Mobile Events

Example

Swipe horizontally on the <p> element to hide it:

$("p").on("swipe",function(){
  $(this).hide();
});

Try it Yourself »

Definition and Usage

The swipe event is triggered when dragged more than 30px in the horizontal direction (and less than 75px in the vertical direction).

Tip:You can swipe quickly in both left and right directions.

Related Events:

  • swipeleft- Triggered when the user swipes across the element from the left by more than 30px.
  • swiperight- Triggered when the user swipes across the element from the right by more than 30px.

Syntax

$("selector").on("swipe",function(event){...})

Parameter Description
function(event) Required. Specifies the function to execute when the swipe event is triggered.

The function has an optional event object, which can be any jQuery event property (e.g., event.target, event.type, etc.). For more information, please refer tojQuery Event Reference Manual 。


实例

More Examples

Event Object
Use the event.target property to return the DOM element that triggered the swipe event.


jQuery Mobile 事件jQuery Mobile Events

Other Extensions