How to reset the style properties to their CSS defaults in javascript?

谁说我不能喝 提交于 2019-11-26 21:46:45

问题


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" not works. How can I reset the color to the CSS default from javascript?


回答1:


If recollection serves, obj.style.color="" should work... I don't know if it's right though.




回答2:


Set the style property values to the empty string:

 obj.style.color = "";


来源:https://stackoverflow.com/questions/3506050/how-to-reset-the-style-properties-to-their-css-defaults-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!