Removing an element using Jquery
is the simplest and most objective thing to do, first you capture the element and then remove it:
$('#elemento').remove();
I came in a situation where I need to remove the element only with pure javascript, but from what I understand, it is necessary to capture the node of the parent element to later remove the target element:
var elemento = document.getElementById("elemento");
elemento.parentNode.removeChild(elemento);
I can not understand the reason for doing this, not even understand how this code is working.
1- How does this code work?
2 - What is the reason why javascript
needs to go to the parent node first and then remove the element?
3 - Because with jquery
is it simple to perform the removal?