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 can set the styles 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 the width
and height
styles to null
to remove the width and height styles of the element
.
Conclusion
To remove style on an element with JavaScript, we can set the styles to null
.
One reply on “How to remove style on an element with JavaScript?”
Type ‘null’ is not assignable to type ‘string’