If you use getElementById
to with document like - document.getElementById
then it always works.
But however, if we perform the same on an element say x
like x.getElementById
, then it returns an error.
The unusual thing about this is that getElementsByClassName
and getElementsByTagName
work on the elements however getElementById
doesn't!