문제

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