Вопрос

A very basic question:

$(element).fadeOut("slow",myFunction());

This doesn't work. What is the correct way to do it?

Это было полезно?

Решение

Try

$(element).fadeOut("slow", myFunction);

Your code, i.e. adding () would actually run the code rather than defining it as callback.

Just some quick console playing:

function test() {}

typeof test // "function"
typeof test() // "undefined"

So the argument needs to be a function and not what a function returns (except that would be function, too).

Другие советы

Try this way

$(element).fadeOut("slow", function(){
   myFunction();
});
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top