发布网友 发布时间:2024-10-24 12:31
共1个回答
热心网友 时间:2024-10-30 22:16
<script>
window.onload = function(){
var button = document.getElementById("button");
var parentNode = button.parentNode;
button.onclick = function(){
for(var i = 0; i<10;i++){
var input = document.createElement("input");
var button1 = document.createElement("input");
input.type = "text";
button1.type = "button";
button1.value = "remove";
button1.onclick = function(){
parentNode.removeChild(input);
parentNode.removeChild(button1);
}
parentNode.appendChild(input);
parentNode.appendChild(button1);
}
}
}
</script>
<div id='all'>
<button id="button">Add</button><br />
</div>