Help - Search - Members - Calendar
Full Version: getElementById mootools/prototype style
Pixel2Life Forum > Member Tutorials and Requests > Forum Tutorial Archives > Miscellaneous Tutorials
curthard89
Ok, i dont need help...but instead of typing document.getElementById blablabla al lthe time, just shorten it by creating a simple function which looks like:

CODE
function $(id){
return document.getElementById(id);
}


and thats it, so instead of
CODE
document.getElementById('myidhere').style.display="none";

u can do
CODE
$('mydivhere').style.display="none";


simple, and saves time, aswell as looking better

smile.gif
Wildhoney
Prototype is a life saver, isn't it! I use that short-hand version all the time, in fact there's so many short-handed ways to do various tasks in Prototype I forget half of them!
rc69
So what is it that you need help with? This sounds more like a tutorial than a question to me.
curthard89
i dont need help, i said that, no where else to put it smile.gif
shameless_w_o_a_d
I believe you could've listed this under the Miscellaneous Tutorials in the Tutorial Free-For-All section.

Still, it's a handy function and I use Prototype as well, so for those who want the simplicity of writing that without the need to use the entire library, this is the answer to their prayers. smile.gif
rc69
QUOTE (curthard89 @ Dec 6 2007, 12:34 PM) *
i dont need help, i said that, no where else to put it smile.gif

Damn my short-term memory!

QUOTE (shameless_w_o_a_d @ Dec 6 2007, 05:41 PM) *
I believe you could've listed this under the Miscellaneous Tutorials in the Tutorial Free-For-All section.

winner_first_h4h.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.