Js事件委托总结
一:javascript:
oUl.onclick=function(e){
//和jq里不一样,这里面的this指向father,可用target代替,eg:alert(target.innerHTML)
}
oUl.onclick=function(e){
//和jq里不一样,这里面的this指向father,可用target代替,eg:alert(target.innerHTML)
}
二:jquery:
live、delegate、on、或者结合closest
$("ul").on("click",function(e){
var str=$(e.target).closest("li").text();
alert(str)
});
live、delegate、on、或者结合closest
$("ul").on("click",function(e){
var str=$(e.target).closest("li").text();
alert(str)
});

浙公网安备 33010602011771号