用原生jQuery如何做Tab点击切换,具体代码是什么
Admin 2022-08-09 群英技术资讯 750 次浏览
在实际应用中,我们有时候会遇到“用原生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进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
JavaScript是一个动态类型语言,在运行时获取变量类型是常用操作。本文将通过示例为大家详细讲讲在JavaScript中如何判断变量类型,感兴趣的可以学习一下
JS手写数组的常用函数有哪些?JS手写数组的常用函数有很多,例如forEach 函数、filter 函数、find 函数、findIndex 函数等等,本文就给大家简单的介绍一下他们的使用,感兴趣的朋友就继续往下看吧。
最终效果展示xhr发起请求!DOCTYPE htmlhtml lang=en head meta charset=UTF-8 meta http-equiv=X-UA-Compatible content=IE=edge meta name=viewport content=width=device-
这篇文章给大家分享的是vue实现购物车全选反选功能的方法。小编觉得挺实用的,因此分享给大家做个参考,文中示例代码介绍的非常详细,感兴趣的朋友接下来一起跟随小编看看吧。
这篇文章主要介绍了js 标签语法使用,在 JavaScript 中提供了标签语句,用于标记指定的代码块,便于跳转到指定的位置。本文来记录一下标签语句的使用方法,需要的朋友可以参考一下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008