Here i want to add new textbox on click of button i.e btnAdd and and also want to remove those newly added textbox by clicking the button i.e btnRemove which is also added along with the new added textbox on a click of btnAdd .
Now the problem is that as i click the add button i.e btnAdd new textbox along with remove button i.e btnRemove is also added as required but as i click on remove button i.e btnRemove the respective textbox and that respective remove button is not removed.
Below is what i have done
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<div id="a">
<input id="Text1" type="text" />
</div>
<input id="btnAdd" type="button" value="Add" />
<script>
$(document).ready(function () {
$("#btnAdd").click(function () {
$("#a").append('<input type="text" id="Text1" value="" />'+'<input type="button" id="btnRemove" value="Remove"/>');
});
$('#btnRemove').click(function () {
$('#Text1').remove();
$(this).remove();
});
});
</script>
</body>
</html>