I was trying to grab the 'value' of a form input with document.getElementById and noticed something strange.
This worked fine:
This, however, would not work:
var grab = document.getElementById("name");
grab.value = "enter name here";
The problem seems to be that if the variable has the same name as the ID, it won't work. Does anyone know why this is? I looked in my JS reference book and on MDN but could not find the answer.
var name = document.getElementById("name");
name.value = "enter name here";