<!DOCTYPE html>
<html>
<body>
<p>单击该按钮可创建 DL、DT 和 DD 元素:描述列表,包含术语和描述。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
var x = document.createElement("DL");
x.setAttribute("id", "myDL");
document.body.appendChild(x);
var y = document.createElement("DT");
var txt1 = document.createTextNode("Coffee");
y.appendChild(txt1);
y.setAttribute("id", "myDT");
document.getElementById("myDL").appendChild(y);
var z = document.createElement("DD");
var txt2 = document.createTextNode("Black hot drink");
z.appendChild(txt2);
document.getElementById("myDL").appendChild(z);
}
</script>
</body>
</html>