<html>
<body>
<p>单击按钮创建一个 FORM 和一个 INPUT 元素。</p>
<button onclick="myFunction()">试一试</button>
<script>
function myFunction() {
var x = document.createElement("FORM");
x.setAttribute("id", "myForm");
document.body.appendChild(x);
var y = document.createElement("INPUT");
y.setAttribute("type", "text");
y.setAttribute("value", "Donald");
document.getElementById("myForm").appendChild(y);
}
</script>
</body>
</html>