案例:javascript案例     状态:可编辑再运行    进入竖版
 运行结果 
x
 
1
<!DOCTYPE html>
2
<html>
3
<body>
4
5
<h3>演示如何创建 LEGEND 元素</h3>
6
7
<p>点击按钮来创建含有文本的 LEGEND 元素。</p>
8
9
<fieldset id="myFieldset">
10
  Name: <input type="text">
11
</fieldset><br>
12
13
<button onclick="myFunction()">试一下</button>
14
15
<script>
16
function myFunction()
17
{
18
var x = document.createElement("LEGEND");
19
var t = document.createTextNode("Personalia:");
20
x.appendChild(t);
21
document.getElementById("myFieldset").appendChild(x);
22
}
23
</script>
24
25
</body>
26
</html>
27