当前位置:编程学习 > JAVA >>

菜单列表折叠

 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
<div > 
            <div > 
                <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> 
            </div> 
            <div > 
                <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> 
            </div> 
            <div > 
                <ul > 
                    <li id="li3"> 
                        <p> 
                            <a href="javascript:" onclick="list(1);" target="_parent">云盘中心</a> 
                        </p> 
                    </li> 
                </ul> 
                <ul id="ul3" > 
                    <li> 
云盘内容管理 
                    </li> 
                </ul> 
            </div> 

作者“丁成云的专栏”
 

补充:web前端 , JavaScript ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,