Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Example of jQuery Fade-Toggle Effect</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(){ // Toggles paragraphs display with fading $(".toggle-btn").click(function(){ $("p").fadeToggle(); }); }); </script> </head> <body> <button type="button" class="toggle-btn">Fade Toggle Paragraphs</button> <p>This is a paragraph.</p> <p>This is another paragraph.</p> </body> </html>