event.target属性

返回哪个DOM元素触发了事件:

$("p, button, h1").click(function(event){
    $("div").html("通过 " + event.target.nodeName + " 元素触发。");
});

猜你喜欢

转载自blog.csdn.net/p_s_p/article/details/129400323