vascop
vascop

Reputation: 5212

How to pass the event object to a named function

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
}

Upvotes: 2

Views: 793

Answers (1)

Sushanth --
Sushanth --

Reputation: 55740

Event is passed to the event handling function as an argument by default

function myHandler(evt) {
    // You can use event object here
}

Upvotes: 1

Related Questions