Calling the actual function from blur ()

I am trying to write some jquery that will call a function when the object is blurry. Due to some requirements in my base code, I need to call a function, for example:

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

instead of this:

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

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

I installed jsfiddle which demonstrates my problem if this helps you to visualize. http://jsfiddle.net/WskKJ/

+3
source share
2 answers
$("object").blur(myFunction);

dont use () when u passes delegate

+8
$("object").blur(function() {
  myFunction();
});
0

Source: https://habr.com/ru/post/1780239/


All Articles