I use alot of getElementById and I have a question about what is the best way to refactor it.
As many already did, I use this code to make it simpler, easier and to reduce the file size:
function $(id){
return document.getElementById(id);
}
But over to what I need help with: is it better to add a variable with the document.getElementById
and just change them in every function I need it? Or, should I just stick to what I already have (the usage of $(id)
)