I am using:
var links = document.getElementsByTagName('a');
to get all links on the page. We need to modify a few.
if I console log links, I get an HTMLCollection of 100+ a elements. If I console log links.length, it's 0.
I've tried everything I can find to convert this to an array but nothing is working.
Array.from(links)
Array.prototype.slice.call(links)
[].forEach.call(links, function (el) {...});
HTMLCollection.prototype[Symbol.iterator] = Array.prototype[Symbol.iterator];
HTMLCollection.prototype.forEach = Array.prototype.forEach;
These all produce an empty array.
Additionally var links = document.querySelectorAll('a'); produces an empty NodeList.
I've run out of options. The initial links variable is very much not empty. So I don't understand why all of these suggested options don't work. Additionally, jQuery is not an option for us.