Updated On: Tutorial updated and rechecked on 29th of October 2024
Views: 1,207
The Javascript below shows and hides a div on a webpage
Two input type buttons are created in HTML. Depending on what button the user clicks, the onClick event calls the Javascript functions showBox() or hideBox()
The showBox() function displays the div box1 by using the document method getElementById('box1') and style.display="block"
The hideBox() function removes the div box1 by using the document method getElementById('box1') and style.display="none"
The div id box1 is styled using the css .box1 class