-3

How to call same javascript function for events like MOUSEOUT and when user press only ENTER key, multiple events calling same js function

aΨVaN
  • 1,104
  • 2
  • 9
  • 18
  • onblur="javascript:search();" this is the html code i have ,need to change this for enter and onblur – aΨVaN Oct 14 '14 at 11:22

1 Answers1

2

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.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95