Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
<head>
    <title>Core Api</title>
    <script>
    function firstElementChild(nodeList) {
        var el = nodeList.firstChild;
        while(el && el.nodeType !== 1) {
            el = el.nextSibling;
        }
        return el;
    }
    window.onload = function()
    {
        var div = document.getElementsByTagName("div").item(0);
        var ul = firstElementChild(div);
        alert(ul);
    }
    </script>
</head>
<body>
    <h2>Árvore</h2>
    <div>
        <ul>
            <li id="item1">
                Primeiro
                <span style="color:blue;">item</span>
                <ul>
                    <li id="item 1.1">item1.1</li>
                    <li id="item 1.2">item1.2</li>
                    <li id="item 1.3">item1.3
                        <ul>
                            <li id="item 1.3.1">item1.3.1
                        </ul>
                    </li>
                </ul>
            </li>
            <li>item2</li>
            <li>item3</li></ul></div>
</body>
</html>
javascripthtmldom
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers