为了账号安全,请及时绑定邮箱和手机立即绑定

大神帮我看看错在哪里了啊,需求实现不了了

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>实践题 - 选项卡</title>
    <style type="text/css">
     /* CSS样式制作 */  
    *{ 
       padding: 0px; margin: 0px; font: 12px; normal:"microsoft yahei";
      }
      
    #tabs{
        width:290px; padding:5px; height:150px; margin:20px;
    }
    
    #tabs ul{
        list-style:none; display: block; height:38px; line-height:30px;
        border-bottom:2px; saddlebrown solid; margin:0px 3px; border:1px solid #aaa;
        border-bottom:none; display:inline-block; width:60px; text-align:center;
    }
    
    #tabs ul li{                                                            
        background:#fff; cursor:pointer; float:left; list-style:none;
        height:28px; line-height:28px;margin:0px 3px; border:1px solid #aaa;
        border-bottom:none; display:inline-block; width:60px; text-align:center;
    }
    
    #tabs ul li.on{
        border-top:20px solid saddlebrown; border-bottom:2px solid #fff;
    }
    
    #tabs div{
        height:120px; line-height:25px; border:1px; solid #33669;
        border-top:none; padding:5px;
    }
    
    .hide{display:none;}
        
    </style>
    <script type="text/javascript">
         
    // JS实现选项卡切换
    var oTab = document.getElementById("tabs");
    var oUl = document.getElementsByTagName("ul");
    var oLis = document.getElementsByTagName("li");
    var oDvis = document.getElementsByTagName("div");
    
    for(var i =0;i<oLis.length;i++){
        oLis[i].index = i;
        oLis[i].onclick = function() {
            for(var n=0;n<oLis.length;n++){
                oLis[n].className = "";
                oDivs[n].className = "hide";
            }
            this.className = "on";
            oDivs[this.index].className="";
        }
    }

    
    
    
    
    </script>
 
</head>
<body>
<!-- HTML页面布局 -->
<div id="tabs">
    <ul>
        <li>房产</li>
        <li>家居</li>
        <li>二手房</li>
    </ul>
    <div>
        275万购昌平邻铁三居 总价20万买一居<br>
        200万内购五环三居 140万安家东三环<br>
        北京首现零首付楼盘 53万购东5环50平<br>
        京楼盘直降5000 中信府 公园楼王现房<br>
    </div>
    <div>
       40平出租屋大改造 美少女的混搭小窝<br>
       经典清新简欧爱家 90平老房焕发新生<br>
       新中式的酷色温情 66平撞色活泼家居<br>
       瓷砖就像选好老婆 卫生间烟道的设计<br>
    </div>
    <div>
     通州豪华3居260万 二环稀缺2居250w甩<br>
     西3环通透2居290万 130万2居限量抢购<br>
     黄城根小学学区仅260万 121平70万抛!<br>
     独家别墅280万 苏州桥2居优惠价248万<br>
     </div>
</div>
</body>
</html>


正在回答

2 回答

你那个方法中的DIVS也写错了  是你上面定义的dvis

0 回复 有任何疑惑可以回复我~

<!DOCTYPE html>

<html>

<head>

    <meta charset="UTF-8">

    <title>实践题 - 选项卡</title>

    <style type="text/css">

     /* CSS样式制作 */

    *{

       padding: 0px; margin: 0px; font: 12px; normal:"microsoft yahei";

      }


    #tabs{

        width:290px; padding:5px; height:150px; margin:20px;

    }


    #tabs ul{

        list-style:none; display: block; height:38px; line-height:30px;

        border-bottom:2px; saddlebrown solid; margin:0px 3px; border:1px solid #aaa;

        border-bottom:none; display:inline-block; width:60px; text-align:center;

    }


    #tabs ul li{

        background:#fff; cursor:pointer; float:left; list-style:none;

        height:28px; line-height:28px;margin:0px 3px; border:1px solid #aaa;

        border-bottom:none; display:inline-block; width:60px; text-align:center;

    }


    #tabs ul li.on{

        border-top:20px solid saddlebrown; border-bottom:2px solid #fff;

    }


    #tabs div{

        height:120px; line-height:25px; border:1px; solid #33669;

        border-top:none; padding:5px;

    }


    .hide{display:none;}


    </style>

    <script type="text/javascript">

window.onload=function(){

    // JS实现选项卡切换

    var oTab = document.getElementById("tabs");

     var oUl = oTab.getElementsByTagName("ul")[0];

    var oLis = oUl.getElementsByTagName("li");

    var oDvis = oTab.getElementsByTagName("div");

console.log(oDvis[0]);

    for(var i =0;i<oLis.length;i++){

        oLis[i].index = i;

        oLis[i].onclick = function() {

            for(var n=0;n<oLis.length;n++){

                oLis[n].className = "";

                oDvis[n].className = "hide";

            }

            this.className = "on";

            oDvis[this.index].className="";

        }

    }

}





    </script>


</head>

<body>

<!-- HTML页面布局 -->

<div id="tabs">

    <ul >

        <li class="on">房产</li>

        <li>家居</li>

        <li>二手房</li>

    </ul>

    <div>

        275万购昌平邻铁三居 总价20万买一居<br>

        200万内购五环三居 140万安家东三环<br>

        北京首现零首付楼盘 53万购东5环50平<br>

        京楼盘直降5000 中信府 公园楼王现房<br>

    </div>

    <div class="hide">

       40平出租屋大改造 美少女的混搭小窝<br>

       经典清新简欧爱家 90平老房焕发新生<br>

       新中式的酷色温情 66平撞色活泼家居<br>

       瓷砖就像选好老婆 卫生间烟道的设计<br>

    </div>

    <div class="hide">

     通州豪华3居260万 二环稀缺2居250w甩<br>

     西3环通透2居290万 130万2居限量抢购<br>

     黄城根小学学区仅260万 121平70万抛!<br>

     独家别墅280万 苏州桥2居优惠价248万<br>

     </div>

</div>

</body>

</html>


0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

大神帮我看看错在哪里了啊,需求实现不了了

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信