zoukankan      html  css  js  c++  java
  • jquery简单实现tab选项卡效果

    html:

    <ul class="tab">
           <li>最新</li>
           <li class="cur">热门</li>
           <li>新闻</li>
     </ul>
     <div>11</div>
     <div class="on">22</div>
     <div>33</div>

    css:

    div{margin:0;padding:0;width:184px;height:200px;border:1px solid #ccc;display:none;}
    .tab{margin:0;padding:0;list-style:none;width:200px;overflow:hidden;}
    .tab li{float:left;width:60px;height:30px;background:#ccc;color:#fff;border:1px solid red; text-align:center;line-height:30px;cursor:pointer; }
    .on{display:block;}
    .tab li.cur{background:blue;}

    js:

      $(document).ready(function(){
            $(".tab li").click(function(){
            $(".tab li").eq($(this).index()).addClass("cur").siblings().removeClass('cur');
    $("div").hide().eq($(this).index()).show();
           //另一种方法: $("div").eq($(".tab li").index(this)).addClass("on").siblings().removeClass('on'); 
    
            });
        });

    来源:http://www.cnblogs.com/web-xiaobai/archive/2012/09/17/2689067.html

  • 相关阅读:
    Java基本概念
    Java基础语法
    Java环境的搭建
    elicpse
    常见编译器EOP
    上传突破学习笔记
    认识ollydbg
    160个Crackerme破解
    python基础(1)
    文件上传
  • 原文地址:https://www.cnblogs.com/dreamflower/p/5584820.html
Copyright © 2011-2022 走看看