zoukankan      html  css  js  c++  java
  • 选项卡

     1 <!DOCTYPE html>
     2 <html>
     3 <head lang="en">
     4     <meta charset="UTF-8">
     5     <title></title>
     6     <style>
     7         div{margin:0;padding:0;width:184px;height:200px;border:1px solid #ccc;display:none;}
     8         .tab{margin:0;padding:0;list-style:none;width:200px;overflow:hidden;}
     9         .tab li{float:left;width:60px;height:30px;background:#ccc;color:#fff;border:1px solid red; text-align:center;line-height:30px;cursor:pointer; }
    10         .on{display:block;}
    11         .tab li.cur{background:blue;}
    12     </style>
    13     
    14 </head>
    15 <body>
    16     <ul class="tab">
    17         <li>最新</li>
    18         <li class="cur">热门</li>
    19         <li>新闻</li>
    20     </ul>
    21     <div>11</div>
    22     <div class="on">22</div>
    23     <div>33</div>
    24     <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.js"></script>
    25     <script>
    26         //tab选项卡 
    27             $(document).ready(function(){
    28                 $(".tab li").click(function(){
    29                     $(".tab li").eq($(this).index()).addClass("cur").siblings().removeClass('cur');
    30                     $("div").hide(200).eq($(this).index()).show(200);
    31                     //另一种方法: $("div").eq($(".tab li").index(this)).addClass("on").siblings().removeClass('on');
    33                 });
    34             });
    35     </script>
    36 </body>
    37 </html>
  • 相关阅读:
    v-cloak
    MVVM
    初识ajax
    装瓶学习法
    回调函数(call back)
    如何让学习变得纯粹?
    异步
    grep用法
    Shell中的&&与||的区别
    shell中使用>/dev/null 2>&1 丢弃信息
  • 原文地址:https://www.cnblogs.com/-CLAY-/p/tab.html
Copyright © 2011-2022 走看看