尽量用<ul>和<li>标签来表示上下级的关系  不要用空格或动态操纵样式表的绝对定位来实现

解决方案 »

  1.   

    直接用table嵌套然后用样式做成树目录就行了沙
      

  2.   

    Array.prototype.distinct = function() {
    var ret = [];
    for (var i = 0; i < this.length; i++) {
    for (var j = i+1; j < this.length;) {
    if (this[i] === this[j]) {
    ret.push(this.splice(j, 1)[0]);
    } else {
    j++;
    }
    }
    }
    return ret;
    }
    //for test
    alert(['a','b','c','d','b','a','e'].distinct());
      

  3.   

    <script> 
    var a;
    function test(x){
    x.disabled=true;
    if(a)a.disabled=false;//如果不加if(a) 下面的a=x将永远得不到执行
    a=x;
    }
    </script> 
    <input type="button" id="button1" value="button1" onclick="test(this);"> 
    <input type="button" id="button2" value="button2" onclick="test(this);"> 
    <input type="button" id="button3" value="button3" onclick="test(this);"> 
    <input type="button" id="button1" value="button4" onclick="test(this);"> 
    <input type="button" id="button2" value="button5" onclick="test(this);">
      

  4.   

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <html>
        <head>
            <style type="text/css">
            div { width:400px; height:25px; border:1px solid #000000; cursor:pointer;}
            </style>
           
        </head>
        <body>
            <div onclick=a(this)>第一层</div>
            <div onclick=a(this)>第二层</div>
            <div onclick=a(this)>第三层</div>
       <div onclick=a(this)>第4层</div>
       <div onclick=a(this)>第5层</div>
       <div onclick=a(this)>第6层</div>
            <div id="two">根目录二</div>
       <script>
             function a(x){
                 var b = "";
                 while (x = x.nextSibling) {
                     if (x.id == "two")return;
                     if (x.nodeType == 3)continue;//兼容firefox 
                     if (b == "") 
                         b = x.style.display == 'none' ? 'block' : 'none';
                     x.style.display = b;
                 }
             }   </script>
        </body>
    </html>