Hi Guys,
Ive stumbled on this phenomenon and it is confusing me a little, Ive added a link to my JS Scribble.
So in essence what I’ve found is if I have a div with and id of “test” that I want to manipulate with getElementById (test.getElementById) I do not need to set a "var test = document.getElementById(“test”); ", JavaScript seems to know intuitively that the “test” in test.getElementById is the id=“test” in the HTML?
But as soon as I want to use a different variable name like x.getElementById, then I need to do the var x = document.getElementById(“test”); which is understandable.
I find it strange that JavaScript is just assuming that the var name I’m using is referring to the id in the HTML?
Is this a new update, an old bug?