Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Event Handling > Gesture Events

Gesture Events

jQuery Mobile offers us some gesture touch events that we can bind to any DOM element. The gesture events offered in jQuery Mobile 1.0 includes:

tap

Executed after a quick touch on the screen.

taphold

Executed when the user touches the screen and maintains it pressed for one second. Useful for showing contextual menus.

swipeleft

Executed when the user swipes a finger from right to left.

swiperight

Executed when the user swipes a finger from left to right.

The next example will bind a swiperight event to a page to go back:

$(document).bind("mobileinit", function() {
   $("#page2").live("swiperight", goBackToPage1);
});

function goBackToPage1() {
   $.mobile.changePage("#page1", { reverse: true });
   $("#page2").unbind("swiperight", goBackToPage1);
}

  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint