DIV+CSS+JS analog tab Toggle Effect Event binding Ie,firefox compatibility _javascript tips

Source: Internet
Author: User
DIV+CSS+JS analog tab, I this version, theoretically can add unlimited tab, and, you just tube content added line, do not need to change JS
Of course, you have to be a div.
<! 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>div+css+js analog tab</title> <style><!--body{margin:0;padding:0; Text-align:center; Background-color: #CCCCCC} a{text-decoration:none} #header ul{padding:0;margin:0} #header ul li{list-style:none; float : left} #header ul Li Span{display:inline-block; border:1px solid #000; cursor:hand;} #ccc {clear:both background-color: #009933; text-align:left} #ccc Div.cont{display:none}--></style> </ head> <body> <div id= "wrap" > <div id= "header" > <ul> <li><span> box 1111</span& gt;</li> <li><span> box 2222</span></li> <li><span> Box 3333</span></ li> <li><span> Box 4444</span></li&Gt </ul> </div> <div id= "CCC" > <div class= "cont" > here is the content of the Caesar. 111.. <br> here is the content of the Caesar. 111.. <br> here is the content of the Caesar. 111.. <br> </div> <div class= "cont" > here is Content Zacchaeus 222. <br> here is the content of the Caesar. 222.. <br> here is the content of the Caesar. 222.. <br> </div> <div class= "cont" > here is the content of the Caesar. 333.. <br> here is the content of the Caesar. 333.. <br> here is the content of the Caesar. 333.. <br> </div> <div class= "cont" > here is the content of the Caesar. 444.. <br> here is the content of the Caesar. 444.. <br> here is the content of the Caesar. 444.. <br> </div> </div> </div> <script type= "text/javascript" ><!--function $ (o) {return D Ocument.getelementbyid (o)} var ospan=$ (' header '). getElementsByTagName (' span '); var odiv=$ (' CCC '). getElementsByTagName (' div '); for (Var i=0;i<ospan.length;i++) {ospan[i].alt=i; Ospan[i].onclick=function () {var nid=parseint (this.alt); Hidall (); This.style.backgroundcolor= ' #fff '; odiv[nid].style.display= ' block '; } function Hidall () {for (Var i=0;i<odiv.length;i++) {Odiv[i].style.displaY= ' None '; Ospan[i].style.backgroundcolor= '; }//--></script> </body> </ptml>
[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.