How to call same javascript function for events like MOUSEOUT and when user press only ENTER key, multiple events calling same js function
1 Answer
You can define more than one event by separating them with a space.
$('selector').on('keyup mouseout click', function(){
// will be called commonly
});
You can use the above with bind also. Also, you could create a separate function and pass it to each handler, but that is overkill, I suppose.
3 Comments
Arijit Mukherjee
this could have been a comment as well :)
Cerbrus
As 20k user you should've know better than to answer something like this. Close-vote as dupe instead...
Amit Joki
@ArijitMukherjee no. It couldn't have been, since it answers the question/