How to hide DOM elements using pure JavaScript

Learn how to hide and then show elements in vanilla JavaScript

How to hide DOM elements using pure JavaScript?

Every element is exposedstyleProperties, which can be used to change CSS style properties.

You can setdisplayProperty is set to "none" (as you did in CSS,display: none;):

element.style.display = 'none'

To show it again, set it toblockorinline:

element.style.display = 'block'

Download mine for freeJavaScript beginner's manual


More js tutorials: