我有一個簡單的輸入元素:找出OnClick事件的註冊方法?
<input class="a" /> // <---notice - no inline onclick function
有人做
$(".a").on('click',function() {alert('1')});
// ...and later
$(".a").on('click',function() {alert('2')});
現在,我想找到:「它的功能被執行單擊元素時」?
我該如何在jquery/Javascript中做到這一點?
p.s.請忽略這裏的匿名函數,我也可以附加一個常規的命名函數。
(IM使用(如jsbin顯示,與1.8.3 - 最新))
http://stackoverflow.com/questions/2223777/jquery-can-i-get-a-reference-to-the-bound -events-on-an-element – eliah
要小心:因爲事件冒泡,事件的處理程序可能不是事件的目標。 – zneak
[查詢針對給定事件類型註冊的事件偵聽器列表]的可能重複(http://stackoverflow.com/questions/3157969/querying-the-list-of-event-listeners-registered-for-a-given -event-type) – zneak