Category: Vanilla Javascript
Added: 29th of December 2022
Viewed: 1,041 times
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