Assistance to implement my own getElementByID()
<p>I am trying to implement my own getElementById() function in Javascript. My idea/algorithm goes like this:</p>

<pre><code>function myGetElemById(id){
    // rootNode I suppose will be the BODY tag.
    rootElem = get elements by TAGNAME (rootNode);
    elems = rootElems.getChildren();
    for(i=0; i&lt;elems.length; i++){
        if(!elems[i].hasChildren()){
            myGetElemById(elems[i]);
        } else {
          if(elems[i].id == id)
              return elems[i];
          else
              return null;  
        }
    }
}
</code></pre>
