Published Nov 20 2018
Psssst! The 2023 WEB DEVELOPMENT BOOTCAMP is starting on FEBRUARY 01, 2023! SIGNUPS ARE NOW OPEN to this 10-weeks cohort course. Learn the fundamentals, HTML, CSS, JS, Tailwind, React, Next.js and much more! โจ
How do you hide a DOM element using plain JavaScript?
Every element exposes a style
property which you can use to alter the CSS styling properties.
You can set the display
property to โnoneโ (like you would do in CSS, display: none;
):
element.style.display = 'none'
To display it again, set it back to block
or inline
:
element.style.display = 'block'