jQuery簡單實現tab選項卡轉場效果,jquerytab

來源:互聯網
上載者:User

jQuery簡單實現tab選項卡轉場效果,jquerytab

抽空把公司項目上用的tab效果封裝了一下,實在是需要用的地方太多了~~~

:

代碼:

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.2/jquery.min.js"></script><title>簡單的tab效果</title><style type="text/css">* {  padding: 0px;  margin:0px}body {  text-align: center}.wrap ul {  overflow: hidden}.wrap li {  float: left;  list-style: none;  margin-right: 10px;  cursor: pointer;  padding: 2px 5px}.link {  cursor: pointer;  color: #F00}.wrap {  width: 200px;  margin: 50px auto}.wrap, .ellipsis {  font-size: 12px;  width: 200px;}.tab_div div {  display: none;  padding: 10px;}.tab_div {  text-align: left;  border: 1px #CCC solid;  height: 200px;  clear: both}.cur {  background: #060;  color: #FFF}#setTab_2{  margin-top: 20px;}</style><script type="text/javascript">$(document).ready(function() {  //tab    $("#setTab").setTab();    $("#setTab_2").setTab();}); /*外掛程式代碼*/(function ($) {  $.fn.setTab = function () {    var getTab=$(this),//this指向調用函數的ID      panels = getTab.children("div.tab_div").children("div"),      tabs = getTab.find("li");     return this.each(function(){      $(tabs).click(function(e) {        var index = $.inArray(this, $(this).parent().find("li"));//this指向li        if (panels.eq(index)[0]) {          $(tabs).removeClass("cur");          $(this).addClass("cur");          panels.css("display", "none").eq(index).css("display", "block");        }      });           }); }})(jQuery);  </script></head><body class="wrap"><div id="setTab"> <ul class="tab_nav">  <li class="cur">國事</li>  <li>軍情</li>  <li>圖片</li> </ul> <div class="tab_div">  <div style="display: block">國事</div>  <div>軍情</div>  <div>圖片</div> </div></div><div id="setTab_2"> <ul class="tab_nav">  <li>國事</li>  <li class="cur">軍情</li>  <li>圖片</li> </ul> <div class="tab_div">  <div>國事</div>  <div style="display: block">軍情</div>  <div>圖片</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.