複製代碼代碼如下:
<!doctype html public' - // w3c // dtd html 4.01 transitional // en'“” http://www.org/tr/tr/html4/loose.dtd“>
<html>
<頭>
<meta http-equiv =“ content-type” content =“ text/html; charset = utf-8”>
<title> jquery2 </title>
<腳本類型=“ text/javascript”>
//創建節點
var additems = function(){
document.getElementById(“ div1”)。innerhtml =“”;
var value = parseInt(document.getElementById('itemnumber')。值);
for(var i = 0; i <value; i ++){
var input = document.createelement(“輸入”);
input.setAttribute(“ type”,“ text”);
var br = document.createelement(“ br”);
document.getElementById(“ div1”)。附錄(輸入);
document.getElementById(“ div1”)。附錄(br);
}
}
</script>
</head>
<身體>
<input type =“ text” id =“ itemsNumber”>
<input type =“ button” id =“ btn” value =“ click” onclick =“ addItems();” >
<div id =“ div1”> </div>
</body>
</html>