Latest web development tutorials
 

jQuery swipe Event

< jQuery Mobile Events

Example

Swipe over a <p> element to hide it:

$("p").on("swipe",function(){
  $(this).hide();
});
Try it Yourself »

Definition and Usage

The swipe event is triggered when the user press down and swipes over an element horizontally by more than 30px (and less than 75px vertically).

Tip: You can swipe in both right and left direction.

Related events:

  • swipeleft - triggered when the user swipes over an element in the left direction
  • swiperight - triggered when the user swipes over an element in the right direction

Syntax

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

Parameter Description
function(event) Required. Specifies the function to run when the swipe event occurs

The function has an optional event object, which can contain any jQuery event properties (e.g. event.target, event.type, etc.) See jQuery Events Reference for more information.

Try it Yourself - Examples

The event object
Using the event.target property to return which DOM element that triggered the swipe event.


< jQuery Mobile Events