I am struggling to understand why there is a difference in the results when I use getElementsByClassName
on two distinct elements:
Check out this code snippet:
let section:HTMLElement = document.getElementById("mainSection");
// When I run this, it returns NodeListOf<Element>
let blah1 = section.getElementsByClassName("blah");
// However, running this line gives me HTMLCollectionOf<Element>
let blah2 = document.getElementsByClassName("blah");
Why does calling the method on section
give me a NodeList
, while calling it on document results in an HTMLCollection
?
According to the MDN Documentation, shouldn't both of them return an HTMLCollection
?