【发布时间】:2019-01-05 14:55:21
【问题描述】:
我需要能够将 div 的背景颜色设置回其原始状态。我可以将它存储在一个变量中并调用它,但想知道为什么我不能使用“初始”。这就是它现在的目的...将 css 属性设置回其初始状态吗?
提前致谢。
testDiv.style.background = "red";
//Shouldn't this turn it back to it's original state of yellow?
testDiv.style.background = "initial";
#testDiv{
background-color: yellow;
width:40px;
height:40px;
}
<div id="testDiv"></div>
【问题讨论】:
标签: css background