复制代码代码如下:
<!doctype html public " - // w3c // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd">
<html>
<head>
<meta http-equiv = "content-type" content = "text/html; charset = utf-8">
<Title> jQuery2 </title>
<script type = "text/javascript">
//创建节点
var additems = function(){
document.getElementById( "div1")。innerhtml = "";
var value = parseint(document.getElementById( 'itemsNumber')。値);
for(var i = 0; i <value; i ++){
var input = document.createelement( "input");
input.setattribute( "type"、 "text");
var br = document.createelement( "br");
document.getElementById( "div1")。appendChild(input);
document.getElementById( "div1")。appendChild(br);
}
}
</script>
</head>
<body>
<入力型= "text" id = "itemsNumber">
<入力型= "button" id = "btn" value = "click" onclick = "additems();" >
<div id = "div1"> </div>
</body>
</html>