I have currently have this code
$(document).on("click", ".element", function(e){
e.preventDefault();
$.ajax({
type:'POST',
url: "ajax/ajax-submit.php",
success:function(data){
if(data == "success") {
console.log("deleted upload");
$(this).parents(".parent-element").remove();
}
},error: function(data){}
});
});
and this is the HTML
<div class="parent-element">
<div class="container">
<button class="element">Remove Parent</button>
</div>
</div>
that $(this)
is not working after success of ajax.
What I want is to remove the parent of this .element
that is .parent-element
.
Note*: This
.element
is a appended element inside.parent-element
.