Latest web development tutorials

jQuery Mobile touch events

Touch event is triggered when the user touches the screen (page).

lamp Touch event is equally applicable and on desktop: Click or slide the mouse!


jQuery Mobile Click

Click event is triggered when the user clicks on the element.

Examples are as follows: click on the <p> element, the hidden current <p> element:

Examples

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

try it"


jQuery Mobile Click and hold (long press)

Click and hold (long press) in the click event does not put (about one second) after the trigger

Examples

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

try it"


jQuery Mobile slide

Slide the event is within the user drag and drop more than one second level 30PX, longitudinal or drag event is less than 20px trigger events:

Examples

$("p").on("swipe",function(){
$("span").text("滑动检测!");
});

try it"


Left slide jQuery Mobile

Swipe left drag event when the user left the trigger element is greater than 30px:

Examples

$ ( "P"). On ( "swipeleft", function () {
alert ( "slide to the left!");
});

try it"


Right sliding jQuery Mobile

Swipe to the right event at the right trigger when the user drags the element is greater than 30px:

Examples

$("p").on("swiperight",function(){
alert("向右滑动!");
});

try it"