Home
Head's Up: I'm in the middle of upgrading my site. Most things are in place, but there are something missing and/or broken including image alt text. Please bear with me while I'm getting things fixed.

Remove Child Elements From An HTML Element With JavaScript

javascript
const parentElement = document.getElementById('someElement')

while (parentElement.children.length > 0) {
    parentElement.children[0].remove()
}

Where alfa is the element to remove the children from

What Didn't Work

The MDN docs say to do this, but it didn't work for me. It wouldn't clear all the elements.

javascript
for (const child of playlists_div.children) {
    child.remove()
}

Not sure why.

(Thanks to i7 from Twitch chat for giving me the solution and saying me a non trivial amount of time)

Footnotes And References