jQuery無限級メニューの簡単な例


CSSを完全に分離して、jQueryで仕様を付加します。つまり、多段階染色のために、カタログツリーと制御仕様を生成するのも簡単です。生成時も仕様を考慮する必要はありません。データテーブルは事前にOrderで並べ替えて、データを読み込まない時にランク付けしたほうがいいと思います。
Netのコントロールはライト級の無限カタログツリーとしてとても使いやすいです。まだ完全ではないので、とりあえずゆっくり修正して、あとは発表します。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>jQuery </title>
    <style type="text/css">
    #menu a {
        color:#fff;
    }
    #menu div {
        /* text-align:center; */
    }
    #menu div a {
        padding-left:20px;
    }
    #menu div.root {
        display:block;
    }
    .list { background:url(list.gif) no-repeat 6px 6px; }
    </style>
    <script type="text/javascript" language="javascript" src="jquery-1.2.3.min.js"></script>
    <script type="text/javascript" language="javascript">
    $(function(){
        // , , , , ……
        _cor = ['#003366', '#0066CC', '#3399FF', '#990000', '#CC0000', '#FF3300', '#FF9900', '#FFCC66', '#FFFFFF'];
        //
        (function Init(i,obj){
            i++;
            //
            _obj = obj.children('div');
            // ,
            if (_obj.length > 0)
                obj.addClass('list');
            $.each(_obj, function(j,o){
                //
                if (i > 0)
                    $(o).hide();
                // , 。
                $(o).css('background-color',_cor[i]);
                //
                Init(i,$(o));
            });
        })(-1,$('#menu'));
    });
    //
    function GotoURL(obj) {
        // “#” , href , , onclick
        if (obj.href.substring(obj.href.length - 1, obj.href.length) != "#") return true;
        //
        $.each($(obj).parent().children('div'), function(i,o){
            $(o).slideToggle('slow');
        });
        return false;
    }
    </script>
</head>
<body>

    <div id="menu">
        <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
        <div> <a href="#" onclick="return GotoURL(this)"> </a>
            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
            <div> <a href="#" onclick="return GotoURL(this)"> </a>
                <div> <a href="#" onclick="return GotoURL(this)"> </a>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                </div>
                <div> <a href="#" onclick="return GotoURL(this)"> </a>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a>
                            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        </div>
                    </div>
                </div>
            </div>
            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
        </div>
        <div> <a href="#" onclick="return GotoURL(this)"> </a>
            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
            <div> <a href="#" onclick="return GotoURL(this)"> </a>
                <div> <a href="#" onclick="return GotoURL(this)"> </a>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                </div>
                <div> <a href="#" onclick="return GotoURL(this)"> </a>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                    <div> <a href="#" onclick="return GotoURL(this)"> </a>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        <div> <a href="#" onclick="return GotoURL(this)"> </a>
                            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                            <div> <a href="#" onclick="return GotoURL(this)"> </a> </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</body>
</html>