复制代码 代码如下:
<!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>
<!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>
标签:
创建元素,节点
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“js创建元素(节点)示例”评论...