This is the second article. For the first article, refer
The Tab page is implemented using jQuery and Ajax technologies.
Code features:
1. Fully implement the Tab logic function. The Tab style is completely controlled by the front-end code and flexible.
2. the tab trigger event is click.
3. The interface is displayed as a table. You only need to configure the class and id of the key object to work.
Copy codeThe Code is as follows:
<! 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> my Tabs tab </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"; // the id of the tab array.
Var tabs = ["# tab1", "# tab2", "# tab3"]; // tab array 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;
}
((Tabspoliciuncs.css ("background-image", "url (" + tab_unselected_bgimg + ")");
((Tabs[i1_0000.css ("color", tab_unselected_txtcolor );
$ (Datas [I]). hide ();
}
Certificate (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>
Zhang Qing (mesh) 9-9-21