LoginSignup
1
2

More than 5 years have passed since last update.

javascript : on()でのアクションの指定は必要なのか

Last updated at Posted at 2018-03-27

とある教材では
下記のようなアクションの指定を推奨している

$(function() {
  $("#title").on("click", function() {
    console.log("クリックされました");
  });
});

on()をしようしてわざわざアクションを指定している

しかし、私は下記のように書いてしまうが、どちらが正しいのか

$(function(){
$("#title").click(function(){
 alert("クリックされました");
  });
});

on()を使用してアクションを指定するのと指定しないで
アクションをそのまま記載するのはどちらが有効なのか

1
2
3

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
2