Is NodeList static or live when using querySelectorAll()
?
Answers:
The
NodeList
returned byquerySelectorAll()
is static. This means that it is a snapshot of the elements that match the specified selector at the time the method is called. If the DOM changes after theNodeList
is created (for example, if elements are added or removed), those changes will not be reflected in theNodeList
.In contrast, a live
NodeList
would automatically update to reflect changes in the DOM. An example of a liveNodeList
is the one returned by methods likegetElementsByTagName()
orgetElementsByClassName()
.