What is a callback function in jQuery and why is it needed in effects?

<div id="b">Box</div>
$('#b').hide(300, function () {
  console.log('2. callback: effect finished');
});
console.log('1. this runs immediately after starting the effect');
Console output

2. callback: effect finished
1. this runs immediately after starting the effect

See Method Chaining and Callbacks.


Learn more about the similar topics:
Tutorials
jQuery Effects: hide, show and toggle
jQuery Fade and Slide Effects
jQuery animate() Method
jQuery Method Chaining and Callbacks
Exercises & Assignments
Write jQuery code to show and hide a panel with one button
Write jQuery code to make a simple accordion
Write jQuery code to make simple tabs
Interview Questions & Answers
What is method chaining in jQuery?
How do you hide and show an element in jQuery?
How do you use the animate() method in jQuery?
What is a callback function in jQuery and why is it needed in effects?
What is the difference between stop(), finish() and delay() in jQuery?