案例:HTML DOM案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<html>
2
<head>
3
4
<script type="text/javascript">
5
function bgChange(bg)
6
{
7
document.getElementById('x').style.background="url(" + bg + ")"
8
}
9
</script>
10
</head>
11
12
<body>
13
<p>本例演示如何向 textarea 插入背景图像。</p>
14
<p>请把鼠标移动到图像上,textarea 会获得一幅背景图像:</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"></td>
20
<td onmouseover="bgChange('/img/eg_bg_09.gif')" 
21
background="/img/eg_bg_09.gif"></td>
22
</tr>
23
</table>
24
25
<form>
26
<textarea id="x" rows="5" cols="20">
27
This example can not be edited
28
because our editor uses a textarea
29
for input,
30
and your browser does not allow
31
a textarea inside a textarea.
32
</textarea>
33
</form>
34
35
</body>
36
</html>