<!DOCTYPE html> <html> <head> <title>Try jQuery Online</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script> $(document).ready(function() { $("button").click(function() { if ($(this).text() === "Hide") { $("p").hide(); $(this).text("Show"); } else { $("p").show(); $(this).text("Hide"); } }) }); </script> </head> <body> <button type="button">Hide</button> <br> <br> Name: <input type="text" name="firstname"> <br> <p id="greet">Welcome!</p> <p id="greet with name">Hello</p> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more