当前位置: 代码迷 >> Web前端 >> 统制页面所有tab切换
  详细解决方案

统制页面所有tab切换

热度:196   发布时间:2012-11-22 00:16:41.0
控制页面所有tab切换

<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>控制页面所有Tab切换</title>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<script>
??? $(function(){

??? ??? $('.tabControl .tabMenu li').click(function(){
??? ???
??? ??? ??? var index=$(this).index();
??? ??? ??? var $tabMenu=$(this).parents('.tabMenu').next().find('ul > li');
??? ??? ??? $(this).parent().find('li').removeClass();
??? ??? ??? $(this).addClass('on');
??? ??? ??? $tabMenu.removeClass();
??? ??? ??? $tabMenu.eq(index).addClass('visible');

??? ??? })
???
??? })
</script>
<style type="text/css">
??? .tabControl{ width:200px }
??? .tabControl li{ list-style:none }
??? .tabMenu li{ float:left;margin-left:1px;cursor:pointer;background:#e3e3e3 }
??? .tabMenu li.on{ background:#ff0000 }
??? .tabDetail li{ display:none }
??? .tabDetail ol li{ display:block }
??? .tabDetail li.visible{ display:block }
</style>
</head>

<body>
??? <div class="tabControl">
??? ??? <div class="tabMenu">
??? ??? ??? <ul>???
??? ??? ??? ??? <li class="on">选项一</li>
??? ??? ??? ??? <li>选项二</li>
??? ??? ??? ??? <li>选项三</li>
??? ??? ??? </ul>
??? ??? </div>
??? ??? <div class="tabDetail">
??? ??? ??? <ul>
??? ??? ??? ??? <li class="visible">
??????????????? ??? <ol>??? ??? ??? ??? <!--如果li中有列表用ol-->
??????????????????? ??? <li>内容一</li>
??????????????? ??? </ol>
??????????????? </li>
??? ??? ??? ??? <li>内容二</li>
??? ??? ??? ??? <li>内容三</li>
??? ??? ??? </ul>
??? ??? </div>
??? </div>
</body>
</html>

  相关解决方案