I am trying to remove a div (and its children, if its contains) from a webpage.
Here is the ajax code I am using.
$.ajax({
url: window.location,
method: 'POST',
dataType: 'text',
data: {
delete_id: 1,
to_delete:deleteID
}, success: function (response) {
//Remove this node
$('.display_stts').removeChild(response); //It does not work
}
});
The ajax code returns this, which I would like to remove from the page.
<div class="card gedf-card">
<div class="card-body ml-10" style="padding:5px;">
<p class="card-text" style="color:blue; font-size:15px; text-align: justify;" name="cmtSpace" id="cmtSpace">
some text some text some text
</p>
<div class="text-right mr-5 replies">
<a class="card-link reply" href="javascript:void(0)" data-stID="124" onclick="stt_func(this)">
<i class="fa fa-reply"></i>continue
</a>
</div>
</div>
</div>
<br>
And this ajax response html code is in a div with the class name class="display_stts":
<div class="display_stts" id="display_stts">
<!-- displaying here -->
</div>
In this class class="display_stts" I have multiple elements like the one returns by ajax. But I would only like to remove that specific one.
How could I manage that ?
Thank you for the taking the time to answer my question.