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 1 year has passed since last update.

addEventListener

Posted at

使い方の流れ

①オブジェクトを取得
ex.
const btn1 = document.getElementById("btn1");

②イベントハンドラ(特定のイベントが起こった時に実行する処理を決めたもの)を実装
ex.
btn1.addEventListener("click",output);

③関数を定義

無名関数を使う場合:
イベントハンドラで処理を実装

処理が多い場合:
イベントハンドラの外で関数を定義
(scryptタグの中で)

function output(e) { console.log(e); }

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?