Skip to content

Instantly share code, notes, and snippets.

@seak0503
Created December 26, 2016 21:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seak0503/f37342a4430613129c3d5214dc0d8673 to your computer and use it in GitHub Desktop.
Save seak0503/f37342a4430613129c3d5214dc0d8673 to your computer and use it in GitHub Desktop.
jqueryのonメソッドのいろいろな使い方

一つのイベント、一つの処理

$(セレクタ).on('イベント', function() {
  処理
});

複数のイベント、一つの処理

$(セレクタ).on('イベント1, イベント2, イベント3', function() {
  処理
});

複数のイベント、イベント一つ一つにそれぞれ別の処理

$(セレクタ).on({
  'イベント1': function() {
    処理1
  },
  'イベント2': function() {
    処理2
  },
  'イベント3': function() {
    処理3
  }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment