View Single Post
Old May 25th, 2006, 2:17 PM   #10
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
document.getElementById("myElement").style.backgroundColour
Even with that (correct here, *high 5* for the UK) spelling of "colour"? Heh

document.getElementById is supported in the vast majority of browsers today, yes. It probably is useless to code around it when the meat of your JS will most likely do something that won't work in the old browsers that don't support document.getElementById anyways. As for caching the output of those functions, that too probably isn't wise. It's not as if the browser is doing anything intensive when it passes you a reference to an element - it's probably just looking it up in a hash table (much like you are doing), except you are doing it in slow JavaScript and it's doing it in some fast compiled language.
Cerulean is offline   Reply With Quote