<!DOCTYPE html>
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
>
<
meta
http-equiv
=
"Content-Type"
content
=
"text/html; charset=utf-8"
/>
<
title
>cookie tab</
title
>
<
script
type
=
"text/javascript"
src
=
"js/jquery-1.8.3.js"
></
script
>
<
script
type
=
"text/javascript"
src
=
"js/jquery.cookie.js"
></
script
>
</
head
>
<
body
>
<
script
type
=
"text/javascript"
>
function nTabs(thisObj, Num) {
if (thisObj.className == "active") return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for (i = 0; i < tabList.length; i++) {
if (i == Num) {
thisObj.className = "active";
document.getElementById(tabObj + "_Content" + i).style.display = "block";
} else {
tabList[i].className = "normal";
document.getElementById(tabObj + "_Content" + i).style.display = "none";
}
}
}
</
script
>
<
div
class
=
"nTab"
>
<
div
class
=
"TabTitle"
>
<
ul
id
=
"myTab1"
>
<
li
class
=
"active"
onclick
=
"nTabs(this,0);"
>注册</
li
>
<
li
class
=
"normal"
onclick
=
"nTabs(this,1);"
>登录</
li
>
</
ul
>
</
div
>
<
div
class
=
"TabContent"
>
<
div
id
=
"myTab1_Content0"
>注册</
div
>
<
div
id
=
"myTab1_Content1"
class
=
"none"
>登录</
div
>
</
div
>
</
div
>
<
script
type
=
"text/javascript"
>
var tabcookievalue = $.cookie("mytab");
if (tabcookievalue != "") {
nTabs($("#myTab1 li").eq(tabcookievalue)[0], tabcookievalue);
}
$("#myTab1 li").click(function () {
$.cookie("mytab", $(this).index());
});
</
script
>
</
body
>
</
html
>