LoginSignup
1
1

More than 5 years have passed since last update.

iOSクリックイベント挙動

Posted at

軽めのjQuery Advent Calendar 2012でのiPhoneのclickイベントの挙動[to-R]に追記で。
- 軽めのjQuery Advent Calendar 2012
- iPhoneのclickイベントの挙動[to-R]

トリック手法

.target { cursor: pointer; }

要素を<a>要素にする

ターゲット要素を<a href="#">にすると、イベントを拾う。

touchstartをイベントに追加する

イベントにtouchstartを追加すると、イベントを拾う。

<script type="text/javascript">
  $(document).ready(function() {
  $("body").on('click touchstart', '.target2', function() {
  console.log(this);
  $(this).css("backgroundColor", "red");
  });
  });
 </script>

サンプルページ(iOSでしか確認していない。)
でもAndroidでもイベント拾うとドキュメンに書いてあった。

sample smartphone toush event

一応、記事書いた。
see also : iOS click クリック イベントの挙動

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1