I'm following some courseware which has a code example which works, but makes no sense. I've read it's good coding practice to use "var" when defining variables, but this example seems to not work when using the "var" statement.
function initiate()
{
content=document.getElementById("secContent");
var button=document.getElementById("send");
button.addEventListener("click", read, false);
}
The code above works, but using the same code and adding "var" at the "content=document.getElementById..." breaks it.
I'm wanting to understand why this seemingly subtle difference makes such a big difference.