用javascript如何实现点击一个按钮就添加一个文本框?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
function set() {
var a = document.getElementById("sss");
var d = document.createElement("br");
var c =a.cloneNode(false);
c.setAttribute("type","text");
var b = document.getElementById("body");
b.appendChild(d);
b.appendChild(c);
}
window.onload=function () {
document.getElementById("aaa").onclick=set;
}
</script>
</head>
<body id="body">
<input type="text" id="sss">
<input type="button" id="aaa" value="添加">
</body>
</html
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>
function set() {
var a = document.getElementById("sss");
var d = document.createElement("br");
var c =a.cloneNode(false);
c.setAttribute("type","text");
var b = document.getElementById("body");
b.appendChild(d);
b.appendChild(c);
}
window.onload=function () {
document.getElementById("aaa").onclick=set;
}
</script>
</head>
<body id="body">
<input type="text" id="sss">
<input type="button" id="aaa" value="添加">
</body>
</html
温馨提示:答案为网友推荐,仅供参考