DEV Community

[Comment from a deleted post]
Collapse
 
kashif_shamaz profile image
Kashif Shamaz • Edited

@bouhm Pretty nice article to glance all the frequently used Vanilla JS Snippets, thanks for writing this!

Just had one observation:
In the Updating/Replacing Elements section, I think you're trying to remove existing dom elements in the List, so I think the following should be the correct code to get existing list element:

// Get the existing list element
const list = document. querySelector('#list-container ul')

// Iterate through list's children and remove them all
while (list.firstChild)
  list.firstChild.remove()
Enter fullscreen mode Exit fullscreen mode