<html>
<body>
<p>单击该按钮可创建一个 SELECT 和一个 OPTION 元素。</p>
<button onclick="myFunction()">试一试</button>
<br><br>
<script>
function myFunction() {
var x = document.createElement("SELECT");
x.setAttribute("id", "mySelect");
document.body.appendChild(x);
var z = document.createElement("option");
z.setAttribute("value", "volvocar");
var t = document.createTextNode("Volvo");
z.appendChild(t);
document.getElementById("mySelect").appendChild(z);
}
</script>
</body>
</html>