菜單列表折疊

 Javascript代碼:

view plain
function list(id) { 
        eval("var ul=ul"+id); 
        eval("var li=li"+id); 
        for (var i=1;i<=3;i++) { 
            eval("var u=ul" + i); 
            eval("var l=li" + i); 
            u.style.display="none";//先把所有的都折疊 
            if (l.className.length != 0) { 
                l.className=""; 
            }   
        } 
        ul.style.display=ul.style.display=="block"?"none":"block";//把需要展開的展開 
        if (li.className.length == 0) { 
            li.className="d_over";//這個地方是換樣式。與折疊無關 
        }        

jsp代碼:

view plain
<p > 
            <p > 
                <ul > 
                    <li id="li1" class="d_over"><p> 
                            <a href="javascript:" onclick="list(1);" target="_parent">信息中心</a> 
                        </p> 
                    </li> 
                </ul> 
                <ul id="ul1" > 
                    <li> 
基本信息管理 
                    </li> 
                    <li> 
代理信息管理                  </li> 
                </ul> 
            </p> 
            <p > 
                <ul > 
                    <li id="li2"> 
                        <p> 
                            <a href="javascript:" onclick="list(1);" target="_parent">材料中心</a> 
                        </p>  
                    </li> 
                </ul> 
                <ul id="ul2" > 
                    <li> 
填報材料管理 
                    </li> 
                    <li>< 
備用材料管理 
                    </li> 
                </ul> 
            </p> 
            <p > 
                <ul > 
                    <li id="li3"> 
                        <p> 
                            <a href="javascript:" onclick="list(1);" target="_parent">雲盤中心</a> 
                        </p> 
                    </li> 
                </ul> 
                <ul id="ul3" > 
                    <li> 
雲盤內容管理 
                    </li> 
                </ul> 
            </p> 

作者“丁成雲的專欄”
 

發佈留言