Sunday, November 8, 2009

Easy Object Call HTML DOM / JavaScript

Here's a handy little function that I use a lot. Instead of having to call document.getElementById('example_tag') which is long and half the time I mis-capitalize the "getElementById", this function saves time and errors with getEle('example_tag') The plus is that it also bypasses a potential error if the element is not there.
function getEle(str){
if(document.getElementById(str)){
return document.getElementById(str);
}
else{
return false;
}
}