style, that can be used to set CSS properties on elements, and style them just like you can with CSS. Let’s try it!
element.style.display = "none"
To display the DOM element again:
element.style.display = "block"
Note: if your DOM element was originally set to
inline-block, just replace the
block value above with one of those values.
In the example above,
style property in a practical sense, you first need to select the DOM element you want to style.
Let’s say you have a button you want to remove from the DOM, called
cta-button. You would do that like this:
const ctaButton = document.querySelector(".cta-button") ctaButton.style.display = "none"