brucelee brucelee - 2 years ago 106
Javascript Question

multiple .on events AND detecting keypress

i run a function like this:

$(document).on('change, focusout', '.something', function(){ ... }

I would like the handler to also execute when keypress == 13.
What's the best approach?

Answer Source

Do a if statement

$(document).on('change focusout keypress', '.something', function(e){
if(e.keyCode == 13 ) {
//code here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download