用原生jQuery如何做Tab点击切换,具体代码是什么
Admin 2022-08-09 群英技术资讯 990 次浏览
在实际应用中,我们有时候会遇到“用原生jQuery如何做Tab点击切换,具体代码是什么”这样的问题,我们该怎样来处理呢?下文给大家介绍了解决方法,希望这篇“用原生jQuery如何做Tab点击切换,具体代码是什么”文章能帮助大家解决问题。Tab 选项卡切换效果在现如今的网页中,运用的也是比较多的,包括点击切换、滑动切换、延迟切换、自动切换等多种效果,在这篇博文里,我们是通过原生 Jquery 来实现 Tab 点击切换的效果
例如:

html
<body> <div style="position: relative;margin-top: 56px;display: flex;justify-content: space-between;width: 1200px;" id="left"> <ul class="gw_b_tab"> <li class="gw_b_item gw_b_item2">111</li> <li class="gw_b_item">222</li> <li class="gw_b_item">333</li> <li class="gw_b_item">444</li> <li class="gw_b_item">555</li> <li class="gw_b_item">666</li> </ul> <div> <div class="gw_b_box" style="display: block;"> <h3 class="gw_box_tit">111</h3> </div> <div class="gw_b_box" > <h3 class="gw_box_tit">222</h3> </div> <div class="gw_b_box"> <h3 class="gw_box_tit">333</h3> </div> <div class="gw_b_box" > <h3 class="gw_box_tit">444</h3> </div> <div class="gw_b_box"> <h3 class="gw_box_tit">555</h3> </div> <div class="gw_b_box" > <h3 class="gw_box_tit">666</h3> </div> </div> </div>
css
*{
padding: 0;
margin: 0;
}
li{
list-style: none;
}
.gw_b_tab{
color: #333333;
width: 240px;
height: 490px;
background: #FFFFFF;
border-radius: 8px;
overflow: hidden;
overflow-y: hidden;
}
.gw_b_item{
height: 82px;
padding: 0 22px;
position: relative;
font-size: 16px;
line-height: 80px;
text-align: center;
cursor: pointer;
border-radius: 8px;
font-weight: bold;
white-space: nowrap;
}
.gw_b_box{
/* display: none; */
width: 880px;
position: absolute;
right: 0;
top: 0;
display: none;
background: #FB6638;
height: 490px;
border-radius: 30px;
}
.gw_b_item2{
background-color: #FB6638;
color: #fff;
}
.gw_box_tit{
height: 48px;
line-height: 48px;
font-size: 24px;
color: #ffffff;
margin-bottom: 18px;
text-align: center;
}
js
<script src="/static/js/jquery-1.11.3.min.js"></script>
<script>
$(function () {
$("#left .gw_b_item").click(function () {
var index = $(this).index();
$(".gw_b_box").eq(index).show();
$(this).addClass('gw_b_item2')
// :eq() 选择器选取带有指定 index 值的元素。
$(".gw_b_box").eq(index).siblings().hide();
$(this).siblings().removeClass('gw_b_item2')
})
})
</script>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
本文给大家介绍vue插槽,对于vue插槽我们之前也有了解过,本文就给大家来介绍一下vue插槽的好处和vue插槽的使用,感兴趣的朋友可以了解看看,那么接下来就跟随小编来学习一下吧。
Element-ui表单校验规则,使得错误提示可以直接在form-item下面显示,无需弹出框,感兴趣的小伙伴们可以参考一下
这篇文章主要介绍了如何利用javascript做简单的算法,主要是以提问的形式犹如练习小例子然后解决问题并附代码说明,需要的朋友可以参考一下
这篇文章给大家分享的是vuex中刷新数据消失的问题的解决方法,下文有具体的问题分析、解决思路及方法,文中示例代码介绍的非常详细,感兴趣的朋友接下来一起跟随小编看看吧。
方法:1、利用getAttribute()方法获取指定class的属性值;2、利用if语句判断获取到的指定class属性值是否为空即可,语法为“if(获取到的指定class属性值=null){不存在代码;}else{存在代码;}”。
成为群英会员,开启智能安全云计算之旅
立即注册关注或联系群英网络
7x24小时售前:400-678-4567
7x24小时售后:0668-2555666
24小时QQ客服
群英微信公众号
CNNIC域名投诉举报处理平台
服务电话:010-58813000
服务邮箱:service@cnnic.cn
投诉与建议:0668-2555555
Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 ICP核准(ICP备案)粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008