How to remove style on an element with JavaScript?

Spread the love

To remove style on an element with JavaScript, we set the style 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 style.width and style.height properties to null to remove the width and height styles.

Leave a Reply

Your email address will not be published. Required fields are marked *