js事件 event.target

我们购物车里,会时不时增加和删除产品时,就会绑定事件和解绑的动作。

<ul>

  <li></li>

  <li></li>

</ul>

例子:在li上未来绑定事件,

$('ul').on('click','li',function(){

  $(this).remove();

});

例子:在ul上绑定事件

$('ul').on('click',function(event){

  var This=event.target;

  $(This).remove();

})

原文地址:https://www.cnblogs.com/love-sea520/p/5867677.html