querySelectorAll well documented here:
https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll
Returns a list of elements within a document (using preliminary traversal of the first order of document nodes) that match the specified group of selectors. The returned object is a NodeList.
On the other hand, the documentation for getElementsByClassName
https://developer.mozilla.org/en-US/docs/Web/API/Document/getElementsByClassName
doesn't have the same confidence.
In fact, I ran into problems with some old browsers - with returning things in different modes in different browsers. Although, this applies to IE6 and can be stabilized according to the HTML5 document.
If you MUST 100% ensure the order of the document, there is always the old walkTheDom code.
Recursion down the DOM tree
Jeremy j starcher
source share