Sometimes, we want to remove style on an element with JavaScript.
In this article, we’ll look at how to remove style on an element with JavaScript.
How to remove style on an element with JavaScript?
To remove style on an element with JavaScript, we set the properties in the style
property to null
.
For instance, we write
const element = document.getElementById("sample_id");
element.style.width = null;
element.style.height = null;
to select the element with getElementById
.
Then we set its style.width
and style.height
properties to null
to remove the width and height styles.
Conclusion
To remove style on an element with JavaScript, we set the properties in the style
property to null
.