1.选项卡案例
示例代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
#body{
font:16px 'Microsoft YaHei',sans-serif;
}
ul{
list-style: none;
margin: 0;
padding: 0;
}
.container{
margin: 100px auto;
width: 800px;
}
.option-list{
height: 40px;
border-bottom: 1px solid #cccccc;
border-left: 1px solid #cccccc;
}
.option-list li{
float: left;
padding: 0px 20px;
height: 39px;
line-height: 40px;
border-top: 1px solid #cccccc ;
border-right: 1px solid #cccccc ;
background-color: #f5f5f5;
cursor: pointer;
}
.option-list li.current{
height: 40px;
background-color: #fff;
}
.card-list li{
display: none;
padding: 20px;
height: 300px;
border: 1px solid #ccc;
border-top: none;
}
.card-list li.current{
display: block;
}
</style>
</head>
<body>
<div class="container">
<div class="option-list">
<ul>
<li class="current">未付款订单</li>
<li>未发货订单</li>
<li>未收货订单</li>
<li>已经完成订单</li>
<li>失效订单</li>
</ul>
</div>
<div class="card-list">
<ul>
<li class="current">这是还没有付款的订单</li>
<li>这是还没有发货发订单</li>
<li>这是还没有收到货的订单</li>
<li>这是已经完成的订单</li>
<li>这是已经失效的订单</li>
</ul>
</div>
</div>
<script src="jquery-3.3.1.min.js"></script>
<script>
$('.option-list li').click(function () {
$(this).addClass('current').siblings('li').removeClass('current');
$('.card-list li').removeClass('current').eq($(this).index()).addClass('current');
})
</script>
</body>
</html>