http://www.sufeinet.com/plugin.php?id=keke_group

苏飞论坛

 找回密码
 马上注册

QQ登录

只需一步,快速开始

分布式系统框架(V2.0) 轻松承载百亿数据,千万流量!讨论专区 - 源码下载 - 官方教程

HttpHelper爬虫框架(V2.7-含.netcore) HttpHelper官方出品,爬虫框架讨论区 - 源码下载 - 在线测试和代码生成

HttpHelper爬虫类(V2.0) 开源的爬虫类,支持多种模式和属性 源码 - 代码生成器 - 讨论区 - 教程- 例子

查看: 1603|回复: 0

[Jquery] jQuery-实现tab切换效果

[复制链接]
发表于 2021-7-5 16:27:53 | 显示全部楼层 |阅读模式
     今天给大家分享一下jQuery实现tab切换的效果,感兴趣的可以的了解一下。
     效果:
      企业微信截图_16254733866225.png
     css样式:
     
[CSS] 纯文本查看 复制代码
.wrap{
  
  box-sizing: border-box;
  width: 500px;
  margin: 50px auto;
 }
 /*清浮动---clearfix*/
 .clearfix {
  *zoom: 1;
 }
 .clearfix:after {
  content: "";
  clear: both;
  display: block;
  height: 0;
  font-size: 0;
  visibility: hidden;
 }
 .list {
  border:1px solid #d9d9d9;
  width: 100%;
  height: 33px;
  box-sizing: border-box;
 }
 .list li:first-child{
  border-left: none;
 }
 .list li{
  list-style: none;
  width: 25%;
  height: 32px;
  border-left:1px solid #d9d9d9;
  font-size: 14px;
  font-family: "楷体";
  line-height: 32px;
  text-align: center;
  float: left;
  /*鼠标样式改变为一个手*/
  cursor: pointer;
  /*字体免选中*/
  -webkit-user-select: none;
  box-sizing: border-box;
 }
 .list-item{
  width: 100%;
 }
 .list-item li{
  list-style: none;
  width: 100%;
  border:1px solid #ccc;
  height: 200px;
  border-top: none;
  padding:8px 10px;
  box-sizing: border-box;
 }
 .wrap .list li.active{
  font-weight: bold;
  color: red;
  border-top: 2px solid red;
  position: relative;
  top:-1px;
  height: 31px;
 }
 .list-item li:first-child{
  display: block;
 }
 .list-item li{
  display: none;
 }

     HTML:
     
[HTML] 纯文本查看 复制代码
<div class="wrap">
  <ul class="list clearfix list-on">
   <li class="active">HTML</li>
   <li>C#</li>
   <li>JAVA</li>
   <li>PHP</li>
  </ul>
  <ul class="list-item">
   <li>苏飞论坛-前端</li>
   <li>苏飞论坛-C#</li>
   <li>苏飞论坛-JAVA</li>
   <li>苏飞论坛-PHP</li>
  </ul>
</div>

     js代码:
     
[JavaScript] 纯文本查看 复制代码
$(".list-on").on("click","li",function(){
   // 设index为当前点击
   var index = $(this).index();
   // 点击添加样式利用siblings清除其他兄弟节点样式
   $(this).addClass("active").siblings().removeClass("active");
   // 同理显示与隐藏
   $(this).parents(".wrap").find(".list-item li").eq(index).show().siblings().hide();
  })

     以上就是实现tab选项卡切换的所有代码了,还有鼠标移动到上面的效果源码里面会体现,如需源码,请点击》》 tab.zip (29.7 KB, 下载次数: 0)


1. 开通SVIP会员,免费下载本站所有源码,不限次数据,不限时间
2. 加官方QQ群,加官方微信群获取更多资源和帮助
3. 找站长苏飞做网站、商城、CRM、小程序、App、爬虫相关、项目外包等点这里
您需要登录后才可以回帖 登录 | 马上注册

本版积分规则

QQ|手机版|小黑屋|手机版|联系我们|关于我们|广告合作|苏飞论坛 ( 豫ICP备18043678号-2)

GMT+8, 2024-4-27 17:23

© 2014-2021

快速回复 返回顶部 返回列表