Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of jQuery Fade-In and Fade-Out Effects with Callback</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> p{ padding: 15px; background: #DDA0DD; } </style> <script> $(document).ready(function(){ // Display alert message after fading out paragraphs $(".out-btn").click(function(){ $("p").fadeOut("slow", function(){ // Code to be executed alert("The fade-out effect is completed."); }); }); // Display alert message after fading in paragraphs $(".in-btn").click(function(){ $("p").fadeIn("slow", function(){ // Code to be executed alert("The fade-in effect is completed."); }); }); }); </script> </head> <body> <button type="button" class="out-btn">Fade Out Paragraphs</button> <button type="button" class="in-btn">Fade In Paragraphs</button> <p>This is a paragraph.</p> </body> </html>