Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery - Get current event

Tags:

jquery

I know I can get the event, by passing it as a parameter of the function:

$(".selector").on("click", function(event) {


});

How can I get it if it is not a parameter of the function?

For instance,

$(".selector").on("click", function() {

// var event = ???

});
like image 220
enb081 Avatar asked Dec 16 '13 10:12

enb081


1 Answers

Even if the parameter is not declared, it is still passed to the function, so you can write:

$(".selector").on("click", function() {
    var evt = arguments[0];
});
like image 72
Frédéric Hamidi Avatar answered Nov 01 '22 10:11

Frédéric Hamidi