document.getElementById("father-id").onclick = function(event) {
event = event || window.event;
let target = event.target || event.srcElement;//兼容 IE
if (target.nodeName.toLowerCase() === "xxx") {
// content
};
}
document.getElementById("father-id").onclick = function(event) {
event = event || window.event;
let target = event.target || event.srcElement;//兼容 IE
if (target.nodeName.toLowerCase() === "xxx") {
// content
};
}
本文标题:实现事件代理
本文链接:https://www.haomeiwen.com/subject/afshoktx.html
网友评论