首页 > 其他 > 详细

选项卡

时间:2017-01-16 16:52:57      阅读:265      评论:0      收藏:0      [点我收藏+]
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>选项卡</title>
    <style type="text/css">
        input{background: white;}
        .active{background: yellow;}
        div{width:200px;height: 100px;background: #ccc;display: none;}
    </style>
    <script type="text/javascript">
    window.onload=function(){
        var aBtn=document.getElementsByTagName(input);
        var aDiv=document.getElementsByTagName(div);
        
        var i=0;
        for (i = 0; i < aBtn.length; i++) {
            aBtn[i].index=i;
            aBtn[i].onclick=function(){
                for(i=0;i<aBtn.length;i++){
                    aBtn[i].className=‘‘;
                    aDiv[i].style.display=none;
                }
                // alert(this.index);
                aDiv[this.index].style.display="block";
                this.className=active;
            }
        };
    }
    </script>
</head>
<body>
    <input type="button" class="active" value="1" >
    <input type="button" value="2">
    <input type="button" value="3">
    <div style="display:block">111</div>
    <div>222</div>
    <div>333</div>
</body>
</html>

 

查看范例

选项卡

原文:http://www.cnblogs.com/Mr-W/p/6290210.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!