如何将事件对象传递给命名函数 [英] How to pass the event object to a named function

查看:90
本文介绍了如何将事件对象传递给命名函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个click事件的事件处理程序。事件处理程序是命名函数而不是匿名函数。如何将事件对象传递给此命名函数?

I have an event handler for the click event. The event handler is a named function instead of an anonymous function. How can I pass the event object to this named function?

// 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
}

这篇关于如何将事件对象传递给命名函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆