--------- Tabs. js -----------------
Copy codeThe Code is as follows:
$ (Function (){
// Init seleted tab
Var on = $. cookie ('current _ tab ');
If (on! = ""&&! IsNaN (on ))
{
$ (". Nav li"). eq (on). addClass ("on"). siblings (). removeClass ();
}
// Default tab
Else
{$. Cookie ('current _ tab ', 0 );}
// Change tab
$ (". Nav li"). click (function (){
Var current_tab = $ (". nav li"). index (this );
$. Cookie ('current _ tab ', current_tab );
Window. location = $ (this). attr ("href ");
});
})
---------------Css.css ----------------------
Copy codeThe Code is as follows:
. Nav {overflow: hidden; height: 20px ;}
. Nav li {float: left; display: inline; padding: 3px ;}
. Nav li a: hover {color: yellow ;}
. Nav li. on {background: #900; color: # FFF ;}
. Nav li. on a {color: # fff ;}
. Nav li. on a: hover {color: yellow ;}
A {text-decoration: none ;}
--------------------- 1.html -----------------------------------
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> untitled document </title>
<Link rel = "stylesheet" type = "text/css" href = "css.css"/>
<Script type = "text/javascript" language = "javascript" src = "jquery-1.4.4.min.js"> </script>
<Script type = "text/javascript" language = "javascript" src = "jquery. cookie. js"> </script>
<Script type = "text/javascript" language = "javascript" src = "tabs. js"> </script>
</Head>
<Body>
<Ul class = "nav">
<Li> <a href = "1.html"> page 1 </a> </li>
<Li> <a href = "2.html"> page 2 </a> </li>
<Li> <a href = "3.html"> page 3 </a> </li>
</Ul>
</Body>
</Html>
The other two pages are the same. You can change the file.
Mark Dzone night owl
From: http://www.cnblogs.com/dzone