Reputation: 4051
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 = ???
});
Upvotes: 5
Views: 7362
Reputation: 111
Simply use below code.
$(".selector").on("click", function(event) {
console.log(event.type); //output = click
});
Upvotes: 0
Reputation: 137
$(".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 :)
Upvotes: 0
Reputation: 262919
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];
});
Upvotes: 9