<script> var i = 1; function add(val){ var obj = document.getElementById("s").tBodies[0]; var row = null; var cell = null; var input= null; row = document.createElement("tr"); cell = document.createElement("td"); input = document.createElement("input"); input.setAttribute("type", "text"); input.setAttribute("value", i.toString()); cell.appendChild(input); row.appendChild(cell); cell = document.createElement("td"); input = document.createElement("input"); input.setAttribute("type", "button"); input.setAttribute("value", "-"); input.onclick=function(){del(this.parentNode.parentNode);}; cell.appendChild(input); row.appendChild(cell); obj.appendChild(row); i+=1; } function del(obj){ document.getElementById("s").tBodies[0].removeChild(obj); } </script> <table id="s"> <thead> <tr> <td><input type="button" onclick="add()" value="+"/></td> </tr> </thead> <tbody> </tbody> </table>