Call actual function from blur()
I'm trying to write some jquery that will call a function when an object 开发者_StackOverflowis 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/
$("object").blur(myFunction);
dont use () when u pass a delegate
$("object").blur(function() {
myFunction();
});
精彩评论