Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

Remove Child Elements From An HTML Element With JavaScript

Code

const parentElement = document.getElementById('someElement')

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

Where _alfa__ is the element to remove the children from

Code

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)

References