This seems like something that would have a quick answer, but I can't find one. Maybe I'm searching the wrong terms? No libraries please, though I don't need cross-browser fallbacks, I'm targeting all the latest versions on this project.
I'm getting some elements:
element = document.querySelectorAll(".someselector");
This is working, but how do I now delete these elements? Do I have to loop through them and do the element.parentNode.removeChild(element);
thing, or is there a simple function I'm missing?
elements[0].parentNode.removeChild(elements[0])
, element[0] is removed from the DOM but not fromelements
. The OP (and myself) is looking for a way to do something likeelements.slice(1)
(if elements was an array rather than aNodeListOf
). Is there a way to remove elements from aNodeListOf
object or do we have to callquerySelectorAll()
after callingremove()
on the element?