4 ms·
> Up until recently one couldn't remove an element without referencing its parent Every node has a reference to it's parent. What's the problem with node.pare
by the_duke 10y ago
> Up until recently one couldn't remove an element without referencing its parent
Every node has a reference to it's parent.
What's the problem with node.parentElement.removeChild(node)?
- maga 10y ago> What's the problem with node.parentElement.removeChild(node)? Being counter-intuitive and verbose. It's but one example of such peculiarities that makes DOM hard to grasp for beginners.
- bzbarsky 10y ago> What's the problem with node.parentElement.removeChild(node)? It's node.parentNode.removeChild(node). And the fact that this is even a mistake that can be made, and is made by people all the timem is part of the problem! "node.remove()" is a lot harder to screw up.