JS tab Option Carter Effect code

Source: Internet
Author: User

 <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "

&lt;html xmlns= "http://www.w3.org/1999/xhtml" &gt; &lt;head&gt; &lt;meta http-equiv= "Content-type" content= "text/" html Charset=utf-8 "/&gt; &lt;title&gt;tab tab &lt;/title&gt; &lt;style type=" Text/css "&gt; Body {font-size:12px;} ul {margin : 0;padding:0;list-style:none;overflow:hidden;} UL li {float:left;height:25px;line-height:25px;padding:0 10px;cursor:pointer;} #cn-lazy, #cn-lazy2{width:380px; height:180px;} #cn-lazy Div, #cn-lazy2 div{width:380px;height:165px;clear:both;display:none}. cn-current {background: #CCC;} &lt;/ style&gt; &lt;/head&gt; &nbsp; &lt;body&gt; &lt;div id= "Cn-lazy" &gt; &nbsp; &lt;ul&gt; &nbsp; &nbsp; &lt;li class= "Cn-cur Rent &gt; Tab One &lt;/li&gt; &nbsp; &nbsp; &lt;li&gt; tab two &lt;/li&gt; &nbsp; &nbsp; &lt;li&gt; tab three &lt;/li&gt; &nbsp; &lt;/ ul&gt; &nbsp; &lt;div style= "Display:block" &gt; Content one &lt;/div&gt; &nbsp; &lt;div&gt; content two &lt;/div&gt; &nbsp; &lt;div&gt; Content three &lt;/div&gt; &lt;/div&gt; &lt;div id= "Cn-lazy2" &gt; &nbsp; &lt;ul&gt; &nbsp; &nbsp; &lt;li class= "Cn-current &gt; Tab One &lt;/li&gt; &nbsp; &nbsp; &lt;li&gt; tab two &lt;/li&gt; &nbsp; &nbsp; &lt;li&gt; tab three &lt;/li&gt; &nbsp; &lt;/ul &gt; &nbsp; &lt;div style= "Display:block" &gt; Content one &lt;/div&gt; &nbsp; &lt;div&gt; content two &lt;/div&gt; &nbsp; &lt;div&gt; content Three &lt;/div&gt; &lt;/div&gt; &nbsp; &lt;script type= "Text/javascript" &gt; Function Cntab (cntable,cnnum) {var tab= document.getElementById (cntable). getElementsByTagName ("ul"); Tab=tab[0].getelementsbytagname ("Li"); var cndiv= document.getElementById (cntable). getElementsByTagName ("div"); var tabnum = tab.length; var cndivnum=cndiv.length; for (i=0;i&lt;tabnum; i++) {tab[i].classname = "";} Tab[cnnum].classname = "Cn-current"; for (i=0;i&lt;cndivnum;i++) {cndiv[i].style.display = ' none ';} cndiv[cnnum].style.display = ' block '; } window.onload=function () {var tabid=new Array ("Cn-lazy", "Cn-lazy2") for (j=0;j&lt;tabid.length;j++) {var tab= document.getElementById (Tabid[j]). getElementsByTagName ("ul"); Tab=tab[0].getelementsbytagname ("Li"); for (i=0;i&lt;tab.length;i++){Tab[i]. DIVID=TABID[J]; Tab[i]. Liid=i; Tab[i].onclick=function () {Cntab (this. Divid,this. LIID); {}}} &lt;/script&gt; &lt;/body&gt; &lt;/html&gt;&lt;/td&gt; &nbsp;&lt;/tr&gt; &lt;/table&gt;
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.