Home  >  Article  >  Web Front-end  >  浅析jQuery事件之on()方法绑定多个选择器,多个事件_jquery

浅析jQuery事件之on()方法绑定多个选择器,多个事件_jquery

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

on()方法绑定多个事件

 

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

 用on()方法绑定多个选择器、多个事件

 

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

以上这篇浅析jQuery事件之on()方法绑定多个选择器,多个事件就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。

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