by Bob Downs
<!DOCTYPE html> <html> <head> <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script> <script src="jqueryTutorialDemo1.js"></script> </head> <body> <h2>This is a heading</h2> <p>This is a paragraph.</p> <p>This is another paragraph.</p> <button>Click me to hide paragraphs</button> </body> </html>
/* Prevent any jQuery code from running before the document is finished loading (is ready). */ $(document).ready(function () { /* Attaches event handler to button element so that when the button is clicked, the instruction inside this function is run. */ $("button").click(function () { /* <p> element is selected and is hidden. */ $("p").hide(); }); });
This is a paragraph.
This is another paragraph.