Jquery - Get current event

Viewed 6421

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 = ???

});
3 Answers
$(".myform .form-control").on("input blur",function(e){

    console.dir(arguments[0].handleObj.type);

});

this code can give current name of event

may that can help you :)

Simply use below code.

$(".selector").on("click", function(event) {
  console.log(event.type); //output = click
});
Related