jQuery Callback Functions


The callback function is performed after the current result is 100% complete.


jQuery Callback Functions

JavaScript statements are made line by line. However, with results, the next line of code may work even if the result is not complete. This can cause errors.

To prevent this, you can create a recurring drive function.

Call re-operation is performed after the end of the current result.

Typical syntax: $(selector).hide(speed,callback);

Examples

The example below contains a callback parameter that is a function to be performed after the cessation of encryption effect:


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

The example below does not have a dial-up parameter, and a warning box will be displayed before completing the encryption effect:


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