案例: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="text" value="把鼠标移动到图像上" size="20">
29
</form>
30
31
</body>
32
</html>