<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./js/jquery.min.js"></script>
<style>
li {
list-style: none;
}
.tab_list li {
float: left;
height: 39px;
line-height: 39px;
padding: 0 20px;
text-align: center;
cursor: pointer;
}
.tab_list .current {
background-color: #c81623;
color: #fff;
}
.item_info {
padding: 20px 0 0 20px;
}
.tab {
position: relative;
}
.tab_con .item {
position: absolute;
display: none;
top: 40px;
left: 40px;
}
li .current {
background-color: pink;
}
</style>
</head>
<body>
<div class="tab">
<div class="tab_list">
<ul>
<li class="current"><a href="https://www.ctyun.cn/portal/link.html?target=%23">商品介绍</a> </li>
<li><a href="https://www.ctyun.cn/portal/link.html?target=%23">商品介绍</a> </li>
<li><a href="https://www.ctyun.cn/portal/link.html?target=%23">商品介绍</a> </li>
<li><a href="https://www.ctyun.cn/portal/link.html?target=%23">商品介绍</a> </li>
<li><a href="https://www.ctyun.cn/portal/link.html?target=%23">商品介绍</a> </li>
</ul>
</div>
<div class="tab_con">
<div class="item" >
商品介绍模块内容
</div>
<div class="item">
规格介绍模块内容
</div>
<div class="item">
售后介绍模块内容
</div>
<div class="item">
商品介绍模块内容
</div>
<div class="item">
商品介绍模块内容
</div>
</div>
</div>
<script>
//点击小li 当前li添加current
$(".tab_list li").click(function() {
//连市编程操作
$(this).addClass("current").siblings().removeClass("current");
//点击得到索引号
var index = $(this).index();
//让下面的item显示
$(".tab_con .item").eq(index).show().siblings().hide();
})
</script>
</body>
</html>
运行结果