3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

onclickとontouchstartの比較テスト

Posted at
<html>
  <head>
    <title>onclick test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no">
    <script>
      leftpx=0;
      function touch(){
        leftpx += 10;
        //alert(leftpx+'px '+document.getElementById('migi').style.left);
        document.getElementById('migi').style.left = leftpx+'px';
      }
      function reset(){
        leftpx = 0;
        document.getElementById('migi').style.left = leftpx+'px';
      }
    </script>
    <style>
      .yaji{font-size:20px; }
      .btn{font-size:20px; width:200px; height:50px; text-align:center; margin-top:20px;}
    </style>
  </head>
<body bgcolor="#FFFFFF" text="#000000">

  <div id="migi" class="yaji" style="position:absolute; left:0px;"></div>
  <div style="clear:both;"></div>

  <div style="position:absolute; top:50px;">
    <button class="btn" onclick="touch()">onclick</button>
    <button class="btn" ontouchstart="touch()">ontouchstart</button>
    <button class="btn" ontouchstart="reset()">reset</button>
  </div>
  
</body>
</html>


3
3
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
3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?