I know that accessing and manipulating the DOM can be very expensive, so I want to do this as efficiently as possible. My situation is that a particular div will always contain a list of elements, however sometimes I want to update this list with a completely different set of elements. In this case, I can create a new list and add it to this div, but I also need to clear the list. What is the best way? Set innerHTML to an empty string? Iterate over child nodes and call "removeChild"? Something else?
source
share