When outputting this code in the console;
var getmythingselems = document.getElementsByClassName("getmythings");
console.log(getmythingselems );
This is returned;
[item: function, namedItem: function]
0: div.gb_ja
length: 1
__proto__: HTMLCollection
But when I try to access the length of the object like below;
console.log(getmythingselems.length)
It returns 0, am I accessing this the correct way?
Note: If I put Settimeout on this for a good few seconds it'll work fine but I'm just confused as to why it would show me some elements initially and then doesn't let me access it.
Edit: Heres the entire code;
var getmythingselems = document.getElementsByClassName("getmythings");
console.log(getmythingselems);
var thethingiwant = "";
if (getmythingselems != null && getmythingselems.length > 0) {
thethingiwant = getmythingselems[0].textContent;
}
console.log(thethingiwant);
return thethingiwant ;