Look this simple example. and try
<html>
<head>
<title>test</title>
<script type="text/javascript">
var counter = 0;
function addNew()
var mainContainer =document.getElementById('mainContainer');
var newDiv = class="highlight">document.createElement('input');
newText.type = "input";
newText.value = counter;
var newDelButton = ^__strong class="highlight">document.createElement('input');
newDelButton.type = "button";
newDelButton.value = "Delete";
newDiv.appendChild(newText);
newDiv.appendChild(newDelButton);
mainContainer.appendChild(newDiv);
counter++;
newDelButton.onclick = function() {
mainContainer.removeChild(newDiv);
}
}
</script>
</head>
<body >
<div id="mainContainer">
<div><input type="text" ><input type="button" value="Add" onClick="addNew()"></div>
</div>
</body>
</html>