Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call actual function from blur()

I'm trying to write some jquery that will call a function when an object is blurred. Because of some of the requirement in my underlying code, I need to call a function, like this:

$("object").blur(myFunction());

instead of like this:

$("object").blur(function() {
  //do stuff
});

Unfortunately, binding the blur event using the first method doesn't work. It actually runs the method on page load, and then never binds the function. What am I doing wrong here?

I've set up a jsfiddle that demonstrates my problem, if it helps you visualize. http://jsfiddle.net/WskKJ/

like image 759
jwegner Avatar asked May 03 '26 09:05

jwegner


1 Answers

$("object").blur(myFunction);

dont use () when u pass a delegate

like image 172
Bonshington Avatar answered May 05 '26 21:05

Bonshington



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!