Book Image

Mastering jQuery Mobile

Book Image

Mastering jQuery Mobile

Overview of this book

Table of Contents (17 chapters)
Mastering jQuery Mobile
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Input with touch


We discussed the swipe, swiperight, and swipeleft events in earlier chapters when we discussed navigating through the pages using touch. We will take a look at a couple of more touch events, which are tap and taphold. The tap event is triggered after a quick touch; whereas the taphold event is triggered after a sustained, long press touch.

The jQuery Mobile tap event is the gesture equivalent of the standard click event that is triggered on the release of the touch gesture. The following snippet of code should help you incorporate the tap event when you need to use it in your application:

$(".selector").on("tap", function(){
    console.log("tap event is triggered");
});

The jQuery Mobile taphold event triggers after a sustained, complete touch event, which is more commonly known as the long press event. The taphold event fires when the user taps and holds for a minimum of 750 milliseconds. You can also change the default value, but we will come to that in a minute. First,...