Checkout this video:
Why you might want to hide a div
There are many reasons why you might want to hide a div in your web page. Maybe you have some warning text that should only be shown when the user tries to submit a form without filling in all the required fields. Or maybe you want to show one div and hide another based on which radio button the user has selected.
Another way to hide a div is to set its visibility property to hidden. This will make the div invisible, but it will still take up space on the page.
If you want to toggle between showing and hiding a div, you can use thetoggle() method. This will change the display property from none to block or vice versa, depending on the current state of the element.
div.style.display = “none”;
You can use the CSS styledisplay property to toggle the display of a div. The style.display property returns the display type of an element, as a string. The display property specifies the display type of an element, i.e. it defines whether an element is displayed as a block or inline element and also the type of box used for displaying an element..
– ” elementById() Method” by W3Schools