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.52k stars 459 forks source link

Use replaceChildren() to clear child nodes #291

Open ziadoz opened 4 months ago

ziadoz commented 4 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