admin管理员组文章数量:1194107
How can I check which event called my function on JavaScript with jQuery?
Like I have:
var mycall= function() {
alert('Which Witch is Which?');
}
$(window).load(mycall);
$(window).resize(mycall);
I understand that I could pass a parameter to the function, still I'm interested in a way to do this without passing any parameters.
How can I check which event called my function on JavaScript with jQuery?
Like I have:
var mycall= function() {
alert('Which Witch is Which?');
}
$(window).load(mycall);
$(window).resize(mycall);
I understand that I could pass a parameter to the function, still I'm interested in a way to do this without passing any parameters.
Share Improve this question edited Nov 24, 2022 at 19:28 Brian Tompsett - 汤莱恩 5,88372 gold badges61 silver badges133 bronze badges asked Mar 29, 2012 at 19:19 JonJon 2,1185 gold badges25 silver badges51 bronze badges 4 |2 Answers
Reset to default 17Use the type
property in the event
object:
var mycall = function(e) {
alert(e.type);
};
Add an event to the function args and then event.type
will give tell which event is triggered. See below,
var mycall= function(e) {
alert(e.type);
}
本文标签: javascriptCheck which event fired the function with jQueryStack Overflow
版权声明:本文标题:javascript - Check which event fired the function with jQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738488945a2089592.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
event.target
. I don't know of one, but I admit it would be a nice thing to have. – Blazemonger Commented Mar 29, 2012 at 19:24arguments
like I wrote. – kirilloid Commented Mar 29, 2012 at 19:27