Why .parentNode is underfined?

HTML:
<div class="question"> 
 <form class="delete-form" type="POST">
 <a class="btn btn-danger delete-btn" data-pk="{{ question.pk }}">Delete</a>
</form>
</div>


JS:
$('.delete-btn').click(function(e) {
e.preventDefault();
 let btn = $(this);

$.ajax({
 type: 'POST',
 url: 'some_url',
 data: {
 // Some data
},
 success: function(data) {
 // Remove question
 btn.parentNode.removeChild(btn) // HERE PROBLEM WAS CALLED
},
 error: function(error) {
 // Danger
}
})
 })


I want to remove .question (parent button)
Why is it when I write console.log(btn) displays the object buttons, when you write btn.parentNode - underfined. How to fix?
April 7th 20 at 11:56
3 answers
April 7th 20 at 11:58
Solution
let btn = $(this);
$ - jquery,
this - HTMLElement,
$(this) object in jquery.

The object of jquery there is no property parentNode. He has method parent().
parentNode is from HTMLElement.

remove()that you suggest, here and there, but you have to understand what you are doing than to rely on a good match.
April 7th 20 at 12:00
April 7th 20 at 12:02
Try this:
btn.parentElement.remove();

Find more questions by tags JavaScriptjQuery