0
0

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 3 years have passed since last update.

JavaScriptのイベントドリブン

Posted at

##イベント

イベント:Userが何かすること
イベントドリブン:イベントに対するJavaScriptの動作

イベントの書き方↓

document.getElementById('ID名').addEventListener('click',function(){ .. });

解説

document.getElementById('ID名')
//まずはIDでエレメントを取得する
.addEventListener('click',function(){ .. });
//addEventListenerでイベントを発火

addEventListenerには2つパラメーターが必要
①イベントの種類(今回はクリックしたとき)
②動かすプログラム

②に関しては無名関数やらなんやらとあるみたいですが、
ひとまず、function(){}と書き方を覚えておけば良い。

以上

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?