I am trying to use the js
document.getElementsByClassName
to locate an html element, which is actually the header of a table.
For the following codes:
console.log(document.getElementsByClassName('gtableheader'));
From the Firebug
, I can see it log a HTMLCollection
, and when I click it, it shows:
-> 0 tr.gtableheader
length 1
So it do locate the element I want.
But when I using:
console.log(document.getElementsByClassName('gtableheader').length);
Then output is 0
. That's so weird, any ideas about this?