Posted in Javascript onJanuary 02, 2014
<!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').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>
js创建元素(节点)示例
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@