I have an Existing div
in my Dom that contains a text Box and a Button.When the User clicks the button a new Div
is dynamically created that contains a textBox and button.What I want to do is that the button that was clicked should be removed as it is recreated dynamically.
<div id="phone" class="row">
<div class="col-md-6">
<input type="text" name="txtTELEPHONENOs" id="txtTELEPHONENOs"/>
</div>
<button class= "btnAddMore">Add More</button>
</div>
$(".btnAddMore").click(function () {
$(this).remove();
$('#phone').after('<div class="row"><div class="col-md-6"><input type="text"/> </div><button class= "btnAddMore">Add More</button></div>');
});
The problem here is that my Jquery code works only once, It removes the clicked button and recreates it only once.The click function is not executed the second time whereas I want it to work on every click. Please can anyone help me solve this problem?