JS 如何清除颜色样式

作者:vkvi 来源:ITPOW(原创) 日期:2008-7-31

已经为某元素设置了背景颜色,利用 JS 如何清除呢?

htmlObject.style.backgroundColor = "transparent";
htmlObject.style.backgroundColor = "";

上述两种方法都是正确的。

已经为某元素设置了字体颜色,利用 JS 如何清除呢?

htmlObject.style.color = "transparent"; //Firefox 中为透明
htmlObject.style.color = "";

这里就不能使用 "transparent",虽然在 IE 中,它和 "" 效果一样,但在 Firefox 中,它表示字体颜色为透明。

相关文章