首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

最简略的Html js做出的tree menu

2012-11-25 
最简单的Html js做出的tree menuhtmlheadmeta http-equivContent-Type contenttext/html chars

最简单的Html js做出的tree menu
<html><head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Reorder TreePanel</title>
<head>
        <script type="text/javascript">
        <!--
            function initNodes(){
            var uls = document.getElementsByTagName("ul");
            var i;
                for(i = 0; i < uls.length; i++)
                    if(uls[i].id != "root")
                        uls[i].style.display = "none";
            }

            function clickNode(id){
            var node = document.getElementById(id);
                if(node.style.display == "none")
                    node.style.display = "block";
                else
                    node.style.display = "none";
                return false;
            }
        -->
        </script>
    </head>
</head>
<body onload="initNodes()">
    Example of a tree menu
    <ul id="root">
        <li><a href="" onclick="return clickNode('r1n1')">Root 1</a>
            <ul id="r1n1">
                <li>Node 1
                </li>
                <li>Node 2
                </li>
                <li>Node 3
                </li>
            </ul>
        </li>
        <li><a href="" onclick="return clickNode('r2n1')">Root 2</a>
            <ul id="r2n1">
                <li><a href="" onclick="return clickNode('r2n1n1')">Node 1</a>
                    <ul id="r2n1n1">
                        <li>Node 1
                        </li>
                        <li>Node 2
                        </li>
                        <li>Node 3
                        </li>
                        <li><a href="#">Node 4</a>
                        </li>
                        <li>Node 5
                        </li>
                        <li>Node 6
                        </li>
                        <li>Node 7
                        </li>
                        <li>Node 8
                        </li>
                        <li>Node 9
                        </li>
                    </ul>
                </li>
                <li>Node 2
                </li>
                <li>Node 3
                </li>
                <li><a href="" onclick="return clickNode('r2n4n1')">Node 4</a>
                    <ul id="r2n4n1">
                        <li>Node 1
                        </li>
                        <li>Node 2
                        </li>
                        <li><a href="" onclick="return clickNode('r2n4n1n3')">Node 3</a>
                            <ul id="r2n4n1n3">
                                <li>Node 1
                                </li>
                                <li>Node 2
                                </li>
                                <li>Node 3
                                </li>
                                <li>Node 4
                                </li>
                            </ul>
                        </li>
                    </ul>
                </li>
                <li>Node 5
                </li>
            </ul>
        </li>
    </ul>
    using style sheet and javascript.
    </body>
</html>

热点排行