Home >Web Front-end >JS Tutorial >A brief analysis of the on() method of jQuery events to bind multiple selectors and multiple events_jquery

A brief analysis of the on() method of jQuery events to bind multiple selectors and multiple events_jquery

WBOY
WBOYOriginal
2016-05-16 15:03:311492browse
$(document).on('click', '#header .top, #main .btn', function () {
   // code...
 });

The on() method binds multiple events

$("table.planning_grid").on({
  mouseenter: function() {
    // Handle mouseenter...
  },
  mouseleave: function() {
    // Handle mouseleave...
  },
  click: function() {
    // Handle click...
  }
}, "td");

Use the on() method to bind multiple selectors and multiple events

$(document).on({
  mouseenter: function() {
    // Handle mouseenter...
  },
  mouseleave: function() {
    // Handle mouseleave...
  },
  click: function() {
    // Handle click...
  }
}, 'click', '#header .top, #main .btn'); 

The above article briefly analyzes the on() method of jQuery events to bind multiple selectors. Multiple events are all the content shared by the editor. I hope it can give you a reference, and I also hope that everyone will support the script. Home.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn