Two triggers for one function? [keyup and focusout]

Welcome,

I have a function

 $ ('# myfield'). keyup (function () {
// do something
}

// - something starts when the user writes something in my field. I notice that when the user uses "autocomplete" from the browser, my function is not executed.

I found an idea to use focusout

Do you have any idea how I can combine this code together without writing a second function like this?

 $ ('# myfield'). focusout (function () {
// do something
}

I would like to combine these 2 functions and not write // do something twice.

considers

+5
source share
2 answers

.bind(), , , , :

$('#myfield').bind("keyup focusout", function () {
  //do something
});

, , blur focusout, :

$('#myfield').bind("keyup blur", function () {
  //do something
});
+15

$('#myfield').bind("focusout",function(){

})
+1

All Articles