JavaScript implementation performance, structure, behavior separation tab effect! _ Navigation Menu

Source: Internet
Author: User
It is characterized by the expansion of convenience, as long as they add the title and content can be automatically initialized.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta http-equiv=" Content-type "content=" text/html; charset=gb2312 "/> <title> Untitled document </title> <script language=" JavaScript "> Window.onload=resettab; function gettabtitle (tab) {var childnodeslist=tab.childnodes; var titlenodes=new Array (); var j=0; var i; for (i=0;i<childnodeslist.length;i++) {if (childnodeslist[i].nodename== "H1") {Titlenodes [J]=childnodeslist[i]; j + +; } return titlenodes; function gettabcontent (tab) {var childnodeslist=tab.childnodes; var tabcontent=new Array (); var j=0; var i; for (i=0;i<childnodeslist.length;i++) {if (Childnodeslist[i].nodename== "DIV") {tabcontent[j]=childnodeslist[i]; j + +; } return tabcontent; function Resettab () {var alldiv=document.getelementsbytagname ("div"); var tab=new Array (); var j=0; var i; for (i=0;i<alldiv.length;i++) {if (alldiv[i].classname== "tabs") {tab[j]=alldiv[i]; j + +; } var tabtitle,tabcontent; for (i=0;i<tab.length;i++) {tabtitle=gettabtitle (tab[i]); Tabtitle[0].classname= "Selecttab"; Tabcontent=gettabcontent (Tab[i]); Tabcontent[0].classname= "Selectcontent"; for (j=1;j<tabtitle.length;j++) {tabtitle[j].classname= "Unselecttab"; Tabcontent[j].classname= "Unselectcontent"; }} function Changtab (tab) {var tabtitle,tabcontent,i; if (tab.classname!= "Selecttab") {tabtitle=gettabtitle (Tab.parentnode); Tabcontent=gettabcontent (Tab.parentnode); for (i=0;i<tabtitle.length;i++) {if (tabtitle[i].classname== "Selecttab") {TABTITL E[i].classname= "Unselecttab"; } if (tabcontent[i].classname== "Selectcontent") {tabcontent[i].classname= "Unselectco Ntent "; } tab.classname= "Selecttab"; for (i=0;i<tabtitle.length;i++) {if (tabtitle[i].classname== "Selecttab") {TABCONTENT[I].C Lassname= "Selectcontent"; Break }}} </script> <style type= "Tex T/css "> <!--body {margin:50px; padding:0px; }. tabs {width:auto; Height:auto; border:0px solid red; }. selecttab,.uNselecttab {border:1px solid #BDDFF9; border-bottom-width:0; width:150px; height:23px; line-height:23px; Vertical-align:middle; Text-align:center; Background-color: #37709B; margin:0; margin-right:18px; Font-weight:bold; font-size:14px; Color: #FFF; Cursor:pointer; Float:left; }. Unselecttab {color: #37709B; Background-color:white; }. selectcontent {border-top:5px #37709b solid; padding-top:8px; Clear:both; }. unselectcontent {display:none; --> </style> </pead> <body> <div class= "tabs" > <p onmouseover= "Changtab (This)" > tab [1] </p> <p onmousemove= "Changtab (This)" > tab [2] </p> <p onmouseover= "Changtab" ( This) "> tab [3] </p> <p onmousemove=" Changtab (This) "> tab [4] </p> <div>1 after a number of steps mentioned above, a A basic CHM file has been produced, before the compilation can also perform a number of features to improve the settings, as described below. </div> <div>2 category Martial arts exhibition category Martial arts exhibition category Martial arts showDistrict Martial Arts exhibition category Martial arts exhibition category martial Arts zone </div> <div>3 after the above steps, a basic CHM file has been produced, before the compilation can also perform a number of perfect function settings, specific as described below. </div> <div>4 categories Martial Arts exhibition category Martial arts exhibition category Martial arts exhibition category Martial arts exhibition category Martial arts section Martial arts zone of Kung Fu area </div> </div> </body> </pt Ml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.