tab切换

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>导航</title>
    <script src="js/jquery-1.10.2.js"></script>
<style>
    *{
        margin: 0;
        padding:0;
        list-style: none;
        font-size: 14px;
        text-decoration: none;
    }
    .tab{
        width:895px;
        height:400px;
        margin:0 auto;
        border:1px solid #eee;
        overflow: hidden;
    }
    .notice-tit{
        height:50px;
        position: relative;
        background: #fff;
    }
    .notice-tit ul{
        position: absolute;
        left:-1px;
    }
    .notice-tit li{
        float: left;
        width:297px;
        height:49px;
        line-height: 49px;
        border:1px solid #eee;
    }
    .notice-tit li a{
        display: block;
        text-align:center;
    }
    .notice-tit li.active a{
        background: #f7f7f7;
        color:green;
    }
    .notice-tit li.kl{
        border-right:none;
    }
    .notice-tit li a:hover{
        background: #f7f7f7;
        color:green;
    }
    .notice-con li a{
        
    }
    .notice-con li{
        display: none;
        float: left;
        width: 298px;
        height:25px;
    }
    .notice-con li.active{
        display: block;
    }
</style>    
</head>
<body>
    <div id="tab" class="tab">
        <div id="notice-tit" class="notice-tit">
            <ul>
                <li class="active"><a href="#" >tab1</a></li>
                <li><a href="#">tab2</a></li>
                <li class="kl"><a href="#">tab3</a></li>
            </ul>
        </div>
        <div id="notice-con" class="notice-con">
                <ul>
                    <li class="active"><a href="#" >内容1</a></li>
                    <li><a href="#">内容2</a></li>
                    <li><a href="#">内容3</a></li>
                </ul>
        </div>
    </div>
<script>
    $(function(){
        var $Tab_li=$('#notice-tit');
        $Tab_li.on('click','li',function(e){
        show($(this));
        var index =$(this).index();
        show($('#notice-con li').eq(index));
        });
        })
        function show($dom){
            $dom.addClass('active').siblings().removeClass('active');
        }
</script>
</body>
</html>





最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容