The first method is to use the native js Code as follows:
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> simple tab </title>
<Style type = "text/css">
Body, ul, li {margin: 0; padding: 0 ;}
Body {font: 12px/1.5 Tahoma ;}
# Outer {width: margin PX; margin: 10px auto ;}
# Tab {overflow: hidden; zoom: 1; background: #000; border: 1px solid #000 ;}
# Tab li {float: left; color: # fff; height: 30px; cursor: pointer; line-height: 30px; list-style-type: none; padding: 0 20px ;}
# Tab li. current {color: #000; background: # ccc ;}
# Content {border: 1px solid #000; border-top-width: 0 ;}
# Content ul {line-height: 25px; display: none; margin: 0 30px; padding: 10px 0 ;}
</Style>
<Script type = "text/javascript">
Window. onload = function ()
{
Var oLi = document. getElementById ("tab"). getElementsByTagName ("li ");
Var oUl = document. getElementById ("content"). getElementsByTagName ("ul ");
For (var I = 0; I <oLi. length; I ++)
{
OLi [I]. index = I;
OLi [I]. onmouseover = function (){
For (var n = 0; n <oLi. length; n ++)
{
OLi [n]. className = "";
This. className = "current ";
}
For (var n = 0; n <oUl. length; n ++)
{
OUl [n]. style. display = "none ";
OUl [this. index]. style. display = "block ";
}
}
}
}
</Script>
</Head>
<Body>
<Div id = "outer">
<Ul id = "tab">
<Li class = "current"> Technology </li>
<Li> tourism </li>
<Li> entertainment </li>
</Ul>
<Div id = "content">
<Ul style = "display: block;">
<Li> Acer R7 Dual Axis deformation evaluation: the touchpad design is too alternative (figure) </li>
<Li> Sony Xperia Tablet Z Tablet evaluation </li>
<Li> Nokia Lumia 925 best WP8 smartphone </li>
<Li> Lenovo IdeaPad S405 Performance Evaluation mainstream endurance to be improved </li>
<Li> small chilies M2 smartphone evaluation: we should be old if we don't change the shell </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
<Li> webpage skin change effect </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
</Ul>
<Ul>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
</Ul>
<Ul>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
</Ul>
</Div>
</Div>
</Body>
</Html>
The second method is implemented using jQuery, and the code is simpler than the first method.
Copy codeThe Code is as follows:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "UTF-8">
<Title> simple tab </title>
<Style type = "text/css">
Body, ul, li {margin: 0; padding: 0 ;}
Body {font: 12px/1.5 Tahoma ;}
# Outer {width: margin PX; margin: 10px auto ;}
# Tab {overflow: hidden; zoom: 1; background: #000; border: 1px solid #000 ;}
# Tab li {float: left; color: # fff; height: 30px; cursor: pointer; line-height: 30px; list-style-type: none; padding: 0 20px ;}
# Tab li. current {color: #000; background: # ccc ;}
# Content {border: 1px solid #000; border-top-width: 0 ;}
# Content ul {line-height: 25px; display: none; margin: 0 30px; padding: 10px 0 ;}
</Style>
<Script type = "text/javascript" src = "js/jquery-1.4.2.min.js"> </script>
<Script type = "text/javascript">
$ (Function (){
Var timeid;
$ ("# Tab"). find ("li"). each (function (index ){
Var sLi = $ (this );
SLi. mouseenter (function (){
Timeid = setTimeout (function (){
SLi. addClass ("current"). siblings (). removeClass ("current ");
SLi. parent (). next (). find ("ul: eq (" + index + ")"). show (). siblings (). hide ();
},300 );
}). Mouseleave (function (){
ClearTimeout (timeid );
})
})
})
</Script>
</Head>
<Body>
<Div id = "outer">
<Ul id = "tab">
<Li class = "current"> Technology </li>
<Li> tourism </li>
<Li> entertainment </li>
</Ul>
<Div id = "content">
<Ul style = "display: block;">
<Li> Acer R7 Dual Axis deformation evaluation: the touchpad design is too alternative (figure) </li>
<Li> Sony Xperia Tablet Z Tablet evaluation </li>
<Li> Nokia Lumia 925 best WP8 smartphone </li>
<Li> Lenovo IdeaPad S405 Performance Evaluation mainstream endurance to be improved </li>
<Li> small chilies M2 smartphone evaluation: we should be old if we don't change the shell </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
<Li> webpage skin change effect </li>
<Li> Lenovo K900's internal structure shows how many domestic artifacts are delivered (photos) </li>
</Ul>
<Ul>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
<Li> fall in love with Seattle, featured U.S. panoramic tours </li>
</Ul>
<Ul>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
<Li> li an announces his resignation from the American drama "Tyrant": You need to rest. </li>
</Ul>
</Div>
</Div>
</Body>
</Html>
The first method is to use native js for reference and other methods, and the second method is written on the basis of the first method...