Remove all child nodes of a list:
// Get the <ul> element with id="myList"
let list = document.getElementById("myList");
// As long as <ul> has a child node, remove it
while (list.hasChildNodes()) {
list.removeChild(list.firstChild);
}
Also in JavaScript:
- how to apply reduce to an empty array in javascript
- how to find area of polygon with coordinates in javascript
- anjular js
- javascript remove first item from array
- angular 8 to 9
- * http://sizzlejs.com/
- loopback unique field
- self invoked function javascript
- get array by array of indices js
- pm2 group console messages
- await async sleep
- Xbonacci
- draw rectangle on canvas javascript
- dart list files in directory
- js is element descendant
- remove parent element javascript
- type checking js vscode
- how to check if item is in list js
- jquery loop through list elements
- AWS JavaScript SDK node
- switch js
- how to trigger events when the document loads in js
- angular injector.create example
- js array return only certain positions