Edit in JSFiddle

//set the default value
var txtId = 1;

//add input block in showBlock
$("#btn").click(function () {
    $("#showBlock").append('<div id="div' + txtId + '">Input:<input type="text" name="test[]" /> <input type="button" value="del" onclick="deltxt('+txtId+')"></div>');
    txtId++;
});

//remove div
function deltxt(id) {
    $("#div"+id).remove();
}
<body>
    <!-- add new item Dynamically in the show block -->
    <div id="showBlock"></div>
    <!-- click the button to add new item -->
    <input type="button" id="btn" value="addItem" />
</body>