+ 2
What is the best method to remove an element in HTML using javascript?
4 Réponses
+ 2
With jQuery you could just use the remove method on the element.
eg: $("ELEMENT").remove();
And as Calvin said if you wanted to remove it's parent then,
$("ELEMENT").parent().remove();
+ 4
refer its parent and then remove element itself.
E.g.
if(element.parentNode) element.parentNode.removeChild(element);
+ 2
The best way it's element.remove()
If you wanna remove the parent
Element.parent().remove()
But this only works with Jquery
- 2
element