点击tone li切换,top也同步切换。down box隐藏显示并增加类名on
因为可能会有多个列表,用一个jq方法实现效果
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title> tab效果测试 </title>
<script src="https://code.jquery.com/jquery-1.7.2.js"></script>
</head>
<body>
<style type="text/css">
.frame{display:table;width: 500px;margin: auto;padding:20px;margin-bottom:20px;background: #f2f2f2;}
.tone{ }
.tone li{display: inline-block;padding:10px;margin: 0 10px;cursor: pointer;background:#ddd;}
.tone li.active{background:#f60}
.top span{display: inline-block;padding: 10px 30px;margin-right: 10px;background: #ddd;}
.top span.on{background: #f60;}
.down{ }
.down .box{display:none; padding:10px;margin-top: 10px;background:#ddd;}
.down .box.on{background: #f60;}
</style>
<div class="frame">
<div class="shell">
<div class="top">
<span class="on">aa</span>
<span>bb</span>
</div>
<ul class="tone">
<li class="active">11</li>
<li>22</li>
</ul>
</div>
<div class="down">
<div class="box on" style="display: block;">11</div>
<div class="box">22</div>
</div>
</div>
<div class="frame">
<div class="shell">
<div class="top">
<span class="on">aa</span>
<span>bb</span>
</div>
<ul class="tone">
<li class="active">11</li>
<li>22</li>
</ul>
</div>
<div class="down">
<div class="box on" style="display: block;">11</div>
<div class="box">22</div>
</div>
</div>
<div class="frame"></div>
...
<script>
//tab
</script>
</body>
</html>