Copy codeThe Code is as follows:
<! 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">
// Create a node
Var addItems = function (){
Document. getElementById ("div1"). innerHTML = "";
Var value = parseInt (document. getElementById ('itemsnumber'). value );
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>
<Input type = "text" id = "itemsNumber">
<Input type = "button" id = "btn" value = "click" onclick = "addItems ();">
<Div id = "div1"> </div>
</Body>
</Html>