1
1

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.

jquery 同じイベントを複数の要素に設定

Last updated at Posted at 2022-04-25

用途

複数の要素に同じイベントを設定したいときに使う。

使用方法

書き方
$('クラスやID, クラスやID, クラスやID').on('イベント', function(){
  // 処理を書く
});

指定したクラスやIDの値のどれかが、指定したイベントに該当した場合に処理が流れる。

$('#hoge, #hogehoge, #hogehogehoge').on('change', function(){
  // #hoge, #hogehoge, #hogehogehogeのどれかの値が変わったときに流れる処理を書く
  console.log("値が変わりました");
});
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?