Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of jQuery Fade-Toggle Effect 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 fade toggling paragraphs $(".toggle-btn").click(function(){ $("p").fadeToggle(1000, function(){ // Code to be executed alert("The fade-toggle effect is completed."); }); }); }); </script> </head> <body> <button type="button" class="toggle-btn">Fade Toggle Paragraphs</button> <p>This is a paragraph.</p> </body> </html>