jquery tab選項卡

來源:互聯網
上載者:User

標籤:style   class   blog   java   http   ext   

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>選項卡效果</title>
<script type="text/javascript" src="js/jquery-1.7b2.js"></script>
<script type="text/javascript">
      $(document).ready(function(){  //頁面載入時
         $(‘.ct:gt(0)‘).hide();
        var hwd=$(‘.box ul li‘);
        /*hwd.hover(function(){  //滑鼠移上去背景變化,hover事件
            $(this).addClass(‘two‘)
            .siblings().removeClass();   //刪除兄弟節點
        });*/
        hwd.hover(function(){
             $(this).addClass(‘one‘)//向匹配的元素添加指定的類名。
             .siblings().removeClass();
        var hwd_index=hwd.index(this);//搜尋匹配的元素,並返回相應元素的索引值,從0開始計數。
        //alert(hwd_index);
        $(‘.ct‘).eq(hwd_index).show().siblings().hide();
        });
    
    });
</script>
<style>
*{ padding:0px; margin:0px;}
body{ font-size:12px; padding:100px;}
ul{ list-style-type:none;}
.box ul{ height:30px; line-height:30px;}
.box ul li{ float:left; padding:0 10px;cursor:pointer; position:relative; background:url(images/bg1.png) repeat-x; border:1px solid #dbe2e7; margin-right:5px; border-bottom:none;}
.content{ width:325px; border:1px solid #dbe2e7; padding:10px;}
* html.content{ margin-top:-1px;}
.box ul li.one{ background:#fff; }
.box ul li.two{ background:orange;}
</style>

</head>

<body>
<div class="box">
<ul>
<li class="one">菜單一</li>
<li>菜單二</li>
<li>菜單三</li>
</ul>
<div class="content">
<div class="ct">菜單一的內容</div>
<div class="ct">菜單二的內容</div>
<div class="ct">菜單三的內容</div>
</div>
</div>
</body>
</html>
效果:

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.