OnClick事件 - 检查哪个是发件人 [英] OnClick event - check which is the sender
本文介绍了OnClick事件 - 检查哪个是发件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
每次点击我的页面上的某些内容(无论是控件还是其他内容)时,是否有办法调用一个事件,然后在该函数中检查哪个是发件人?
Is there a way to call one event every time when something on my page is clicked (whether a control or something else), and then in that function to check which is the sender?
推荐答案
是这样的吗?
$(document).click(function(e) {
console.log(e.target);
});
这将捕获文档中的所有点击并记录事件开始的节点。这是一个大锤的方法,但没有理解这个问题,这是我能做的最好的。
This will capture all clicks in the document and log the node on which the event started. It's a bit of a sledgehammer approach, but without understanding the problem it's the best I can do.
这篇关于OnClick事件 - 检查哪个是发件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文