我有一个用于点击事件的事件处理程序。事件处理程序是命名函数而不是匿名函数。如何将事件对象传递给这个命名函数?
// usual example
$(".sel").click(function(ev) {
// do stuff which involves the event
});
// my case
$(".sel").click(myHandler);
function myHandler() {
// hopefully do stuff which involves the event
}
最佳答案
事件默认作为参数传递给事件处理函数
function myHandler(evt) {
// You can use event object here
}
关于javascript - 如何将事件对象传递给命名函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17768295/