Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of jQuery Toggle Effect with Callback</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <style> p{ padding: 15px; background: #F0E68C; } </style> <script> $(document).ready(function(){ // Display alert message after toggling paragraphs $(".toggle-btn").click(function(){ $("p").toggle(1000, function(){ // Code to be executed alert("The toggle effect is completed."); }); }); }); </script> </head> <body> <button type="button" class="toggle-btn">Toggle Paragraphs</button> <p>This is a paragraph.</p> </body> </html>