phuocng / html-dom

Common tasks of managing HTML DOM with vanilla JavaScript. Give me 1 ⭐if it’s useful.
https://phuoc.ng/collection/html-dom
MIT License
6.53k stars 461 forks source link

Use replaceChildren() to clear child nodes #291

Open ziadoz opened 5 months ago

ziadoz commented 5 months ago

The replaceChildren() node with no parameters can be used to quickly clear a node's children:

https://developer.mozilla.org/en-US/docs/Web/API/Element/replaceChildren#emptying_a_node