I have a JS script with tons of functions, on big on is this:
function id(i) {
if(document.getElementById)
return document.getElementById(i);
return;
}
It just saves me many bytes in typing out document.getElementById() each time. My problem is I frequently add and remove classes and other attributes from elements. I want to be able to do this:
id('main').addClass("someClass");
Does anyone know any good Javascript Prototyping tutorials which can explain this? Thanks.