Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the document</title> <script src="https://code.jquery.com/jquery-3.5.0.min.js"></script> <style> p { padding: 20px; background: blue; } </style> </head> <body> <button type="button" class="toggle-btn">Toggle</button> <p>Lorem Ipsum is simply dummy text.</p> <script> $(document).ready(function() { // Display alert message after toggle paragraphs $(".toggle-btn").click(function() { $("p").toggle(2000, function() { // Code to be executed alert("The toggle effect is completed."); }); }); }); </script> </body> </html>