欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jQuery Mobile 觸摸事件實(shí)例

 更新時(shí)間:2016年06月04日 11:58:57   投稿:yourber  
這篇文章主要演示了5個(gè)jQuery Mobile 觸摸事件實(shí)例,需要的朋友可以參考下。

觸摸事件在用戶(hù)觸摸屏幕(頁(yè)面)時(shí)觸發(fā)。

必須引入jQuery庫(kù)和jQuery Mobile庫(kù),如下:

<script src=">
<script src="
>

1.jQuery Mobile 點(diǎn)擊

點(diǎn)擊事件在用戶(hù)點(diǎn)擊元素時(shí)觸發(fā)。

如下實(shí)例:當(dāng)點(diǎn)擊 <p> 元素時(shí),隱藏當(dāng)前的 <p> 元素:

復(fù)制代碼 代碼如下:
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("tap",function(){
    $(this).hide();
  });                      
});
</script>
<div data-role="main" class="ui-content">
  <p>敲擊我,我會(huì)消失。</p>
  <p>敲擊我,我會(huì)消失。</p>
  <p>敲擊我,我也會(huì)消失。</p>
</div>

2.jQuery Mobile 點(diǎn)擊不放(長(zhǎng)按)

點(diǎn)擊不放(長(zhǎng)按) 事件在點(diǎn)擊并不放(大約一秒)后觸發(fā)

復(fù)制代碼 代碼如下:
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("taphold",function(){
    $(this).hide();
  });                      
});
</script>
<div data-role="main" class="ui-content">
  <p>如果您敲擊并保持一秒鐘,我會(huì)消失。</p>
  <p>敲擊并保持住,我會(huì)消失。</p>
  <p>敲擊并保持住,我也會(huì)消失。</p>
</div>

3.jQuery Mobile 滑動(dòng)

滑動(dòng)事件是在用戶(hù)一秒內(nèi)水平拖拽大于30PX,或者縱向拖曳小于20px的事件發(fā)生時(shí)觸發(fā)的事件:

復(fù)制代碼 代碼如下:
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("swipe",function(){
    $("span").text("滑動(dòng)檢測(cè)!");
  });                      
});
</script>
<div data-role="main" class="ui-content">
  <p>在下面的文本或方框上滑動(dòng)。</p>
  <p style="border:1px solid black;height:200px;width:200px;"></p>
  <p><span style="color:red"></span></p>
</div>

4.jQuery Mobile 向左滑動(dòng)

向左滑動(dòng)事件在用戶(hù)向左拖動(dòng)元素大于30px時(shí)觸發(fā):

復(fù)制代碼 代碼如下:
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("swipeleft",function(){
    alert("您向左滑動(dòng)!");
  });                      
});
</script>
<div data-role="main" class="ui-content">
  <p style="border:1px solid black;margin:5px;">向左滑動(dòng) - 不要超出邊框!</p>
</div>

5.jQuery Mobile 向右滑動(dòng)

向右滑動(dòng)事件在用戶(hù)向右拖動(dòng)元素大于30px時(shí)觸發(fā):

復(fù)制代碼 代碼如下:
<script>
$(document).on("pagecreate","#pageone",function(){
  $("p").on("swiperight",function(){
    alert("向右滑動(dòng)!");
  });                      
});
</script>
<div data-role="main" class="ui-content">
  <p style="border:1px solid black;margin:5px;">向右滑動(dòng) - 不要超出邊框!</p> 
</div>

以上就是本文的全部?jī)?nèi)容,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論