WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

jQuery Callback Functions


A callback work is executed after the present impact is 100% finished.


jQuery Callback Functions

JavaScript explanations are executed line by line. Nonetheless, with impacts, the following line of code can be run despite the fact that the impact isn't done. This can make errors.

To keep this, you can make a callback function.

A callback work is executed after the present impact is finished.

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

Examples

The model beneath has a callback parameter that is a capacity that will be executed after the shroud impact is completed:

Example with Callback

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

The model underneath has no callback parameter, and the alarm box will be shown before the shroud impact is completed:

Example without Callback

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