1//removing element by ID
2var element = document.getElementById("myElementID");
3 element.parentNode.removeChild(element);
1//remove a dom element
2var element = document.getElementById("someId");
3 element.parentNode.removeChild(element);
4
5//remove element from array
6var colors=["red","green","blue","yellow"];
7var blue=colors.splice(2, 1);//first arg is array index to remove
8//colors is now ["red","green","yellow"]
9
1var elem = document.querySelector('#some-element');
2elem.parentNode.removeChild(elem);
3
1// delete an element from the dom
2var elem = document.querySelector('#some-element');
3elem.parentNode.removeChild(elem);
4
5
6// keep element in dom
7var elem = document.querySelector('#some-element');
8elem.style.display = 'none';