js remove child elements
while (myNode.firstChild) {
myNode.removeChild(myNode.lastChild);
}var myDiv = document.getElementById("myDivID");
myDiv.innerHTML = "";//remove all child elements inside of myDivfunction deleteChild() {
let e = document.querySelector("ul");
//e.firstElementChild can be used.
let child = e.lastElementChild;
while (child) {
e.removeChild(child);
child = e.lastElementChild;
}
}
let btn = document.getElementById(
"btn").onclick = function() {
deleteChild();
} node.parentNode.parentNode.removeChild(node.parentNode)
Also in JavaScript:
- freecodecamp cdn
- iife
- stopped typing jquery
- in in sequelize
- javascript dataurl to blob
- does json only support ascii
- how to send message to specific client using ws node js
- javascript addeventlistener
- How to replace an array vue.js
- js select option value when selected
- react check if string is mail
- NullInjectorError: R3InjectorError HttpClient
- reverse words in a string javascript
- check if value is NaN
- nodejs docker
- JavaScript function that generates all combinations of a string.
- javascript to uppercase
- how to wirte json format
- javascript números pegar apenas o decimal
- iterate through list javascript
- drupal tag filter ajax content
- javascript option
- if keypress javascript
- keydown shift tab angular