五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > Tab頁界面之二,用jQuery技術(shù)實現(xiàn)

Tab頁界面之二,用jQuery技術(shù)實現(xiàn)

文章來源:365jz.com     點擊數(shù):273    更新時間:2009-09-22 09:37   參與評論

    這個tab頁是把數(shù)據(jù)全部取回來再顯示,所以沒有數(shù)據(jù)緩存的特點。但是因為數(shù)據(jù)全部是顯示的html代碼,所以對搜索引擎是友好的,也許對seo有好處。

    代碼特點:
    1,完全實現(xiàn)Tab邏輯功能,Tab的樣式完全交由前端代碼控制,很靈活。
    2,tab頁觸發(fā)事件是click。
    3,界面以table布局,只需要配置關(guān)鍵對象的class和id 即可工作。

<!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=utf-8" />
<title>我的Tabs選項卡</title>
<style type="text/css">
  body {font-size:12px; }
  .tab {background:url(images/gray.png); cursor:hand;}
</style>
<script type="text/javascript" src="jquery/jquery-1.2.6.min.js"></script>
<script type="text/javascript">
  $(document).ready(function()
  {
  //-------------------------
    var tabclass = ".tab"; //tab 數(shù)組 id
    var tabs = ["#tab1", "#tab2", "#tab3"]; //tab 數(shù)組 id
    var datas = ["#data1", "#data2", "#data3"];

    var tab_selected_bgimg = "images/green.png";
    var tab_unselected_bgimg = "images/gray.png";

    var tab_selected_txtcolor = "#ff6600";
    var tab_unselected_txtcolor = "#666666";

    var curr_index;
    $(tabclass).click(function()
    {
      for(var i=0;i<tabs.length;i++)
      {
        if($(tabs[i]).attr("id")==$(this).attr("id"))
        {
          curr_index = parseInt(i)+1;
        }
        $(tabs[i]).css("background-image", "url("+ tab_unselected_bgimg +")");
        $(tabs[i]).css("color", tab_unselected_txtcolor);
        $(datas[i]).hide();
      }
      $(this).css("background-image", "url("+ tab_selected_bgimg +")");
      $(this).css("color", tab_selected_txtcolor);
      $("#data"+curr_index).show();
    });
    $("#tab1").click();
  //-----------------
  });

</script>

</head>

<body>

<table border="0" width="500" height="25" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
  <td width="97" class="tab" id="tab1">tab1</td>
  <td width="30"></td>
  <td width="97" class="tab" id="tab2">tab2</td>
  <td width="30"></td>
  <td width="97" class="tab" id="tab3">tab3</td>
  <td width="149"></td>
</tr>
</table>

<table border="1" width="500" height="60" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
  <td>
    <div id="data1">
      this is data1
    </div>
    <div id="data2">
      this is data2
    </div>
    <div id="data3">
      this is data3
    </div>
  </td>
</tr>
</table>

</body>

張慶(網(wǎng)眼) 2009-9-21
來自“網(wǎng)眼視界”:http://blog.why100000.com
“十萬個為什么”電腦學(xué)習(xí)網(wǎng):http://www.why100000.com

如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答!! 點擊進(jìn)入論壇

發(fā)表評論 (273人查看0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴(yán)禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號