On a php generated page there are several elements like this:
<td class="defaultTDStyle" style="color:userDefinedCustomColor" id="myTDId"></td>
So there is a default style and I apply several extra styles that override the style defined in the CSS.
Is there a way to remove these added styles from javascript? It seems the obj.style.color="default"
and obj.style.color="auto"
don't work. How can I reset the color to the CSS default from javascript?
Use the initial keyword to set a property to its initial value. Use the inherit keyword to make an element's property the same as its parent. Use the revert keyword to reset a property to the value established by the user-agent stylesheet (or by user styles, if any exist).
CSS variables have access to the DOM, which means that you can change them with JavaScript.
This diminutive CSS Reset employs the universal selector ( * ) to reset the padding and margins on all elements to zero. It is often expanded to include border: 0; outline: 0 to also reset these values to zero, nada, zilch.
Use the style. removeProperty() method to remove CSS style properties from an element, e.g. box. style. removeProperty('background-color') .
If recollection serves, obj.style.color=""
should work... I don't know if it's right though.
Set the style property values to the empty string:
obj.style.color = "";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With