Introduction to jQuery
JQuery Syntax
JQuery Effects
JQuery HTML
JQuery Traversing
jQuery Callbacks is a key concept that helps you run code after an animation or effect finishes.
A callback is a function that is executed after the current effect is complete.
In jQuery, many effects like .hide(), .show(), .slideDown(), .fadeOut(), .animate(), etc. allow you to pass a callback function as the last parameter.
$(selector).effect(duration, callback);
Or simply:
$(selector).effect(callback);
The example below has a callback parameter that is a function that will be executed after the hide effect is completed:
Try it yourself
The example below has no callback parameter, and the alert box will be displayed before the hide effect is completed:
Try it yourself