Categories
JavaScript Answers

How to remove style on an element with JavaScript?

Spread the love

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.

Leave a Reply

Your email address will not be published.

If you like the content of this blog, subscribe to my email list to get exclusive articles not available to anyone else.