这个是在网上找的资料
<div >
<a >点我</a>
<a >点我吧</a>
<input ></input>
<input ></input>
</div>
$("#parent *").click(function(e){
if(e.target == $("#a1")[0]){
alert("你点了链接一!");
}else if(e.target == $("#a2")[0]){
alert("你点了链接二!");
}else if(e.target == $("#b1")[0]){
alert("你点了按钮一!");
}else if(e.target == $("#b2")[0]){
alert("你点了按钮二!");
}
});
可以试试我这个,因为jQuery选择器的原因,所以一定要指定父级,否则会执行多次。
相关文章:
-
2020-04-19
-
2018-11-26
-
2021-12-12
-
2019-10-31
-
2021-11-02
-
2021-12-09
-
2021-12-09