<html>
<head>
<title></title>
<script>
function show() {
var textbox = document.createElement('input');
textbox.type = 'text';
textbox.id = "textBox";
var btn = document.createElement("button");
btn.innerHTML = "X";
btn.id = "button";
btn.onclick = close;
document.getElementById("display").appendChild(textbox);
document.getElementById("display").appendChild(btn);
}
function close() {
document.getElementById("textBox").style.display = "none";
document.getElementById("button").style.display = "none";
}
</script>
</head>
<body>
<a href="#" onclick="show()">add contact</a>
<div id="display">
</div>
</body>
</html>
In this code I was manged to generate the textbox with a button. when we click on the button in the first generating textbox button pair it is working. but it is not working or multiple pairs. I need to close each pair by clicking the button in the each pair.