jQuery CallbackMethods


Callback functions execute after the current animation is 100% complete.


jQuery Animation Issues

Many jQuery functions involve animations. These functions may passspeedordurationas an optional parameter.

Example:$("p").hide("slow")

speedordurationThe parameter can be set to many different values, such as "slow", "fast", "normal", or milliseconds.

Example

The following example invokes the callback function after the hide effect is fully completed:

Using the callback example

$("button").click(function(){ $("p").hide("slow",function(){ alert("The paragraph is now hidden"); }); });

Try it yourself

The following example has no callback function; the alert box will pop up before the hide effect completes:

Without callback

$("button").click(function(){ $("p").hide(1000); alert("The paragraph is now hidden"); });

Online Example »
Other Extensions