To begin with, each item that you want to hide/show should have a unique HTML ID. Let’s begin with a very simple HTML page.
<h1>This is my title</h1> <div id="content"> <h2>Div1 Follows</h2> <div id="div1"> This is where my first div will be. </div> <h2>Div2 Follows</h2> <div id="div2"> This is where my second div will be. </div> </div>
We will then write a function that will hide all of the appropriate divs (in this case, div1 and div2).