Welcome,
I have function
$('#myfield').keyup(function () { //do something }
//- do something is runing when user write something in myfield. I notice, when user use "auto complete" from browser, my function is not executed.
I found idea, to use focusout
Do you have any idea how can i combine that code together, without writing second function like this ?
$('#myfield').focusout(function () { //do something }
I would like to put this 2 functions together, and don't write //do something, two times.
regards
You can use .bind()
which takes a space separated list of events to bind your handler to, like this:
$('#myfield').bind("keyup focusout", function () {
//do something
});
Though, unless you need some special propagation, I'd stick with blur
over focusout
, just a preference really:
$('#myfield').bind("keyup blur", function () {
//do something
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With