Help us understand the problem. What is going on with this article?


More than 1 year has passed since last update.

ontouchstart, ontouchmove, ontouchendは存在しない。

console.log(onmousedown); // => null
console.log(ontouchstart); // => Uncaught Error: 'ontouchstart' is not defined


// マウスで左クリックする時のイベント
addEventListener('mousedown', function() { console.log('new mouse'); });

// 古いやり方(非推奨だが、可能)
onmousedown = function() { console.log('old mouse'); };

// スマホなどでタップする時のイベント
addEventListener('touchstart', function() { console.log('new touch'); });

// 古いやり方も可能かと思いきや、不 可 能
ontouchstart = function() { console.log('old touch'); };



Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away