jQuery Mobile タッチ・イベント

❮ 前章へ 次章へ ❯

タッチ・イベントは、ユーザが画面(ページ)に触れるとトリガされます。

タッチイベントはデスクトップコンピュータでも機能します:マウスをタップしてスワイプしてください!


jQuery Mobile タップ

タップ・イベントは、ユーザーが要素をタップするとトリガーされます。

下の例は次の通りです:<p> 要素でタップイベントが発火したとき;現在の <p> 要素を非表示にします:

$("p").on("tap",function(){
  $(this).hide();
});
Try it Yourself »

jQuery Mobile タップ・フォールド

タップ・フォールド・イベントは、ユーザが要素をタップして、1秒間タップしたままにするとトリガされます:

$("p").on("taphold",function(){
  $(this).hide();
});
Try it Yourself »

jQuery Mobile スワイプ

スワイプ・イベントは、要素の上を横に 30px 以上スワイプすると発生します:

$("p").on("swipe",function(){
  $("span").text("Swipe detected!");
});
Try it Yourself »

jQuery Mobile 左スワイプ

swipeleft イベントは、要素の上を左方向に 30px 以上スワイプしたときにトリガーされます:

$("p").on("swipeleft",function(){
  alert("You swiped left!");
});
Try it Yourself »

jQuery Mobile 右スワイプ

swiperight イベントは、要素の上を右方向に 30px 以上スワイプしたときにトリガーされます:

$("p").on("swiperight",function(){
  alert("You swiped right!");
});
Try it Yourself »


❮ 前章へ 次章へ ❯