How to clear all inline styles from an HTML element
In short: set the styles to the empty string to clear all styles (for example,
myElement.style.cssText = "";).
After trying a few less-than-ideal solutions, I found a one-liner that solved the problem: all I had to do was set its
cssText to the empty string, like this:
myElement.style.cssText = "";
That cleared all inline styles! As far as I can tell, this worked in every browser I tested (though I didn't test less than IE8).
Hopefully this little trick can help you.
Posted on .