How to call same javascript function for events like MOUSEOUT and when user press only ENTER key, multiple events calling same js function
            Asked
            
        
        
            Active
            
        
            Viewed 181 times
        
    -3
            
            
        - 
                    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 Answers
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
- 
                    
- 
                    2As 20k user you should've know better than to answer something like this. Close-vote as dupe instead... – Cerbrus Oct 14 '14 at 11:24
- 
                    @ArijitMukherjee no. It couldn't have been, since it *answers* the question/ – Amit Joki Oct 14 '14 at 11:25
