Code:
    function FCE(e) { // {{{
        /* First Child Element - only tags, not text. */
        e = e.firstChild;
        do {
            e = e.nextSibling;
        } while (e && e.nodeType != 1);
        return e;
    } // }}}
     
    window.onload = function() {
        var li = document.getElementsByTagName('li');
        for (var i = 0; i < li['length']; i++) {
            console.log(li[i]); // Outputs <li>
            console.log(li[i].firstChild); // Outputs <a href=...'>
            console.log(FCE(li[i])); // Outpus null.
        }
    };
The html is the traditional
Code:
<li><a href='...>text</a></li>
I just can't understand what is wrong with the line
Code:
console.log(FCE(li[i]));
Why is it returning null? The two lines above do return what is supposed to be returned, and I used them just as a test.

Also, the reason why I am trying the custom FCE(e) function, is that I want to be sure that the real first child element will be returned, and not, for instance, a text node or a "white space" node.

Any help would be appreciated.