jQuery Mobile 觸摸事件
觸摸事件在用戶觸摸屏幕(頁面)時(shí)觸發(fā)。
 | 觸摸事件同樣可應(yīng)用與桌面電腦上:點(diǎn)擊或者滑動(dòng)鼠標(biāo)! |
jQuery Mobile 點(diǎn)擊
點(diǎn)擊事件在用戶點(diǎn)擊元素時(shí)觸發(fā)。
如下實(shí)例:當(dāng)點(diǎn)擊 <p> 元素時(shí),隱藏當(dāng)前的 <p> 元素:
實(shí)例
$("p").on("tap",function(){
? $(this).hide();
});
嘗試一下 ?
jQuery Mobile 點(diǎn)擊不放(長按)
點(diǎn)擊不放(長按) 事件在點(diǎn)擊并不放(大約一秒)后觸發(fā)
實(shí)例
$("p").on("taphold",function(){
? $(this).hide();
});
嘗試一下 ?
jQuery Mobile 滑動(dòng)
滑動(dòng)事件是在用戶一秒內(nèi)水平拖拽大于30PX,或者縱向拖曳小于20px的事件發(fā)生時(shí)觸發(fā)的事件:
實(shí)例
$("p").on("swipe",function(){
? $("span").text("Swipe detected!");
});
嘗試一下 ?
jQuery Mobile 向左滑動(dòng)
向左滑動(dòng)事件在用戶向左拖動(dòng)元素大于30px時(shí)觸發(fā):
實(shí)例
$("p").on("swipeleft",function(){
? alert("You swiped left!");
});
嘗試一下 ?
jQuery Mobile 向右滑動(dòng)
向右滑動(dòng)事件在用戶向右拖動(dòng)元素大于30px時(shí)觸發(fā):
實(shí)例
$("p").on("swiperight",function(){
? alert("You swiped right!");
});
嘗試一下 ?