实例代码“Ctrl+/”提示“F11/ESC”全屏 返回 格式化 恢复 运行
x
 
1
<!DOCTYPE html>
2
<html>
3
<head>
4
<style>
5
div {color: red; }
6
</style>
7
</head>
8
<body>
9
10
<div>
11
<h1 id="bc">Hello World</h1>
12
13
<ul>
14
<li id="a">Item one</li>
15
<li id="b">Item two</li>
16
<li id="c">Item three</li>
17
</ul>
18
19
</div>
20
21
<p>点击“尝试一下”按钮把第二个列表项的 color 属性的值设置为 "initial":</p>
22
23
<button onclick="myFunction()">尝试一下</button>
24
25
<script>
26
function myFunction()
27
{
28
document.getElementById("b").style.color = "initial";
29
}
30
</script>
31
32
<p><b>注意:</b>Internet Explorer 或 Opera 15 及其之前的版本不支持 initial 关键字作为一个属性值。</p>
33
34
</body>
35
</html>