function layoutMod() {
standardId = document.getElementById("standard");
fancyId = document.getElementById("fancy");
standardId.onclick = function() {
standard();
};
fancyId.onclick = function() {
fancy();
};
};
How can I use the onclick events defined above in a function??? Is it a good practice to load the function at page load?? I need to define in a function the onclick event beacuse I don't want to use global variables.
varkeyword. The way you have it now all your variables are not limited to just this function and are probably global! Use strict mode to help avoid common issues like these. Second, yourstandardIdandfancyIdvariables seem to be poorly named.getElementByIdreturns a DOM element, not an id