Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Multiple Chained Callbacks</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style> #box{width:150px;height:80px;background:#9575cd;color:#fff;display:flex;align-items:center;justify-content:center;margin-bottom:10px;} #log{font-family:monospace;} </style> </head> <body> <button id="btn">Run Sequence</button> <div id="box">Box</div> <div id="log"></div> <script> function log(msg) { $("#log").append("<div>" + msg + "</div>"); } $("#btn").on("click", function () { $("#log").empty(); log("Step 1: fading out..."); $("#box").fadeOut(400, function () { log("Step 2: sliding down..."); $(this).slideDown(400, function () { log("Step 3: fading in..."); $(this).fadeIn(400, function () { log("Sequence complete!"); }); }); }); }); </script> </body> </html>
Output