用jQuery技術(shù)實(shí)現(xiàn)Tab頁界面之二
更新時(shí)間:2009年09月21日 17:16:55 作者:
這個(gè)tab頁是把數(shù)據(jù)全部取回來再顯示,所以沒有數(shù)據(jù)緩存的特點(diǎn)。但是因?yàn)閿?shù)據(jù)全部是顯示的html代碼,所以對(duì)搜索引擎是友好的,也許對(duì)seo有好處。
這是第二篇文章,第一篇可以參考
Tab頁界面,用jQuery及Ajax技術(shù)實(shí)現(xiàn)
代碼特點(diǎn):
1,完全實(shí)現(xiàn)Tab邏輯功能,Tab的樣式完全交由前端代碼控制,很靈活。
2,tab頁觸發(fā)事件是click。
3,界面以table布局,只需要配置關(guān)鍵對(duì)象的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選項(xiàng)卡</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
Tab頁界面,用jQuery及Ajax技術(shù)實(shí)現(xiàn)
代碼特點(diǎn):
1,完全實(shí)現(xiàn)Tab邏輯功能,Tab的樣式完全交由前端代碼控制,很靈活。
2,tab頁觸發(fā)事件是click。
3,界面以table布局,只需要配置關(guān)鍵對(duì)象的class和id 即可工作。
復(fù)制代碼 代碼如下:
<!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選項(xiàng)卡</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
您可能感興趣的文章:
- 通過jquery實(shí)現(xiàn)tab標(biāo)簽瀏覽效果
- JQuery學(xué)習(xí)筆記 實(shí)現(xiàn)圖片翻轉(zhuǎn)效果和TAB標(biāo)簽切換效果
- jquery tools之tabs 選項(xiàng)卡/頁簽
- jquery easyui的tabs使用時(shí)的問題
- JQuery Tab選項(xiàng)卡效果代碼改進(jìn)版
- jQuery EasyUI 中文API Layout(Tabs)
- 用jQuery打造TabPanel效果代碼
- 基于JQuery的6個(gè)Tab選項(xiàng)卡插件
- 基于Jquery的回車成tab焦點(diǎn)切換效果代碼(Enter To Tab )
- jQuery版Tab標(biāo)簽切換
- jQuery Tab插件 用于在Tab中顯示iframe,附源碼和詳細(xì)說明
- jQuery EasyUI API 中文文檔 - Tabs標(biāo)簽頁/選項(xiàng)卡
- 基于jquery tab切換(防止頁面刷新)
- 基于jquery的圖片輪播 tab切換組件
- 使用jquery實(shí)現(xiàn)div的tab切換實(shí)例代碼
- jquery sortable的拖動(dòng)方法示例詳解
- jQuery操作表格(table)的常用方法、技巧匯總
- jquery easyui 結(jié)合jsp簡(jiǎn)單展現(xiàn)table數(shù)據(jù)示例
- jQuery插件slick實(shí)現(xiàn)響應(yīng)式移動(dòng)端幻燈片圖片切換特效
- jquery移動(dòng)端TAB觸屏切換實(shí)現(xiàn)效果
相關(guān)文章
讀jQuery之七 判斷點(diǎn)擊了鼠標(biāo)哪個(gè)鍵的代碼
jQuery中的which即可以是鍵盤的鍵值,也可以是鼠標(biāo)的鍵值。2011-06-06jquery實(shí)現(xiàn)焦點(diǎn)輪播效果
本文主要介紹了jquery實(shí)現(xiàn)焦點(diǎn)輪播效果的示例代碼,具有很好的參考價(jià)值,下面跟著小編一起來看下吧2017-02-02jQuery實(shí)現(xiàn)的簡(jiǎn)單動(dòng)態(tài)添加、刪除表格功能示例
這篇文章主要介紹了jQuery實(shí)現(xiàn)的簡(jiǎn)單動(dòng)態(tài)添加、刪除表格功能,涉及jQuery事件響應(yīng)及表格元素動(dòng)態(tài)操作相關(guān)實(shí)現(xiàn)技巧,需要的朋友可以參考下2017-09-09基于jquery用于查詢操作的實(shí)現(xiàn)代碼
通過javascript得到用戶操作改變url參數(shù)從而實(shí)現(xiàn)某些功能,如查詢(具體的查詢由服務(wù)器端代碼得到url中的參數(shù)組成查詢語句實(shí)現(xiàn))。2010-05-05jquery.qtip提示信息插件用法簡(jiǎn)單實(shí)例
這篇文章主要介紹了jquery.qtip提示信息插件用法,結(jié)合簡(jiǎn)單實(shí)例形式分析了該插件用于顯示提示信息的相關(guān)使用技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06JS實(shí)現(xiàn)點(diǎn)擊生成UUID的方法完整實(shí)例【基于jQuery】
這篇文章主要介紹了JS實(shí)現(xiàn)點(diǎn)擊生成UUID的方法,結(jié)合完整實(shí)例形式分析了基于jQuery實(shí)現(xiàn)的隨機(jī)字符串生成相關(guān)操作技巧,需要的朋友可以參考下2019-06-06