jquery 事件绑定

1.

//bind
.bind(events [,eventData], handler)

//on
.on(events [,selector]  [,data], handler);
//如:筛选出ul下的li给其绑定click事件;
$('ul').append('<li>js new li<li>');');
$('ul').on('click', 'li', function(){console.log('click');})    //动态添加的li会绑定事件
$('ul li').on('click', function(){console.log('click');})       //动态添加的li不会绑定事件

  

posted @ 2018-08-29 14:26  liuyj_vv  阅读(104)  评论(0编辑  收藏  举报