Note on closure:
Closure are means through which inner function can refer to the variables present in their outer function after their parent function have already terminated.
A statement like,
document.getElementById("main");
needs to wait until the page is loaded.
Until the page is fully loaded, id like "main" might not exist.
To wait until page is loaded, do this:
window.onload = loaded;
function loaded() {
Snippets
window.onload = loaded;
function loaded() {
// find the element with id of 'main'
var obj = document.getElementById("main");
// change it's border styling
obj.style.border = "1px solid red";
// initialize a call back that will occur in one second
setTimeout(function() {
// which will hide the object
obj.style.display = 'none';
}, 1000);
}
.