I'm dynamically trying to create a div which has a content and delete button whenever this 'createaction' button is clicked.
I have an onclick function whenever the delete button is clicked. but my code here does not work, and I think it is because the delete button id is the same.
In what way can i make these buttons unique from each other?
$("#createAction").click(function() {
var targetDate = $("#targetDate").val();
var newAction = "<div id='actionsDiv'>
<div>
<button type='button' id='delete'> delete</button>
</div>
<label>Target Date:</label>" + targetDate + "
</div>";
$("#actionPlanInfo").append(newAction);
$("#targetDate").val('');
$("#delete").on("click", function() {
var confirmation = confirm('Are you sure you want to delete this action plan/s?');
if (confirmation == true) {
$(this).parent().parent().remove();
}
});
});