首页 > Web开发 > 详细

jquery tab切换

时间:2019-04-13 16:34:32      阅读:142      评论:0      收藏:0      [点我收藏+]

首先引入jquery.js

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!--自动适应手机屏幕宽度的方法-->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <!--微信缓存-->
    <!--no-cache指示请求或响应消息不能缓存-->
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link rel="stylesheet" href="css/index.css">
    <script src="js/jquery-3.3.1.min.js"></script>
    <title>****</title>
</head>

<body style="background: #e6e6e6;"> 
    <div class="content">
        <div class="contentLeft">
            <span class="contentT on">摄像头1</span>
            <span class="contentT">摄像头2</span>
            <span class="contentT">摄像头3</span>
            <span class="contentT">摄像头4</span>
        </div>
        <div class="contentRight">
            <div class="contentD active">
                1111
                <!-- <div class="controller">摄像头控制方向</div>
                <div class="direction">
                    <img src="img/left.png" class="dirLeft">
                    <img src="img/top.png" class="dirTop">
                    <img src="img/right.png" class="dirRight">
                    <img src="img/botton.png" class="dirBotton">
                </div> -->
            </div>
            <div class="contentD ">
                2222
            </div>
            <div class="contentD">
                333
            </div>
            <div class="contentD">
                4444
            </div>
        </div>
    </div>
</body>
<script>
    $(document).ready(function () {
        // tab切换
        $(".contentT").off("click").on("click", function () {
            var index = $(this).index();
            $(this).addClass("on").siblings().removeClass("on");
            $(".contentD").eq(index).addClass("active").siblings().removeClass("active");
        });
    })
</script>

</html>
.content{
    margin-top: 240px;
    width: 100%;
    display: flex;

}
.contentLeft{
    width: 30%; 
    margin-right: 20px;  
    color: #666666;
    text-align: center;
}
.contentT{
    display: inline-block;
    height: 60px;
    line-height: 60px;
    background: white;
    width: 100%;
}
.contentT.on{
    display: inline-block; 
    color: #8ec21f;
    background: #e6e6e6;
}
.contentRight{
    flex: 1;
    background: #e6e6e6;
    margin-right: 20px;
}
.controller{
    text-align: center;
    margin: 50px 0px 10px 0px
}
.direction{
    background: white;
    padding: 10px;
    box-sizing: border-box;
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: 8px;
}
.direction img{
    width: 60px;
    height: 60px;
    position: absolute;
}
.dirTop{
    top: 10px;
    left: 50%;
    margin-left: -30px;
}
.dirRight{
    right: 10px;
    top: 50%;
    margin-top: -30px;
}
.dirBotton{
    bottom: 10px;
    left: 50%;
    margin-left: -30px;
}
.dirLeft{
   left: 10px;
   top: 50%;
   margin-top: -30px;
}
.contentD{
    display: none;
}
.contentD.active{
    display: block;
} 

技术分享图片

jquery tab切换

原文:https://www.cnblogs.com/xiaoxiao2017/p/10701543.html

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