案例:HTML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
<script type="text/javascript">
4
function bgChange(bg)
5
{
6
document.getElementById('x').style.background="url(" + bg + ")"
7
}
8
</script>
9
</head>
10
11
<body>
12
13
<p>本例演示如何向按钮插入背景图像。</p>
14
<p>请把鼠标移动到图像上,按钮会获得一幅背景图像:</p>
15
16
<table width="300" height="100">
17
 <tr>
18
  <td onmouseover="bgChange('/img/eg_bg_08.gif')" 
19
      background="/img/eg_bg_08.gif">
20
  </td>
21
  <td onmouseover="bgChange('/img/eg_bg_09.gif')" 
22
      background="/img/eg_bg_09.gif">
23
  </td>
24
</tr>
25
</table>
26
27
<form>
28
<input id="x" type="button" value="Mouse over the images">
29
</form>
30
31
</body>
32
</html>