JS General Code: Tab options cartoon with JS code

Source: Internet
Author: User

I have been using the JS Common tab class:

<! 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> sliding door general js</title> <style type=" Text/css "> <!--body{margin:0px; Padding:0px;font-size:12px;background: #eee; line-height:20px;} . bodyer{width:760px;margin:20px auto auto;border:1px dotted #ccc; background: #fff;} t_rt{text-align:right;} h1,h2,h3 , h4,h5,h6{font-weight:bold;margin:0px;padding:0px;font-size:12px} ul,li{margin:0px;padding:0px;} li{ List-style-type:none;} h1{margin:10px;padding-right:10px;padding-bottom:5px;border-bottom:1px dotted #ccc; preview{margin:10px;padding : 10px;overflow:hidden;background: #eee;} . cont{padding:10px}. Cls{clear:both}. Hidden{display:none; #sourse {border:1px dotted #ccc; width:600px;height : 300px;margin:0px Auto;} . textdiv{margin:10px 40px 10px;text-align:center;} h2{margin:0px 10px;background: #ccc;p adding:5px; example{margin:10px;background: #FFF; border:1px dotted #ccc; padding:10px;} . scrolldoorframe{width:400px;margin:0px Auto;overflow:hidden; scrollul{width:400px;border-bottom:1px Solid #CCC ; overflow:hidden;height:35px;} . Scrollul Li{float:left; bor03{border:1px solid #ccc; border-top-width:0px; sd01{cursor:pointer;border:1px solid # Ccc;background: #FFF; margin:5px;padding:2px;font-weight:bold;} . sd02{cursor:pointer;border:0px solid #CCC; margin:5px;padding:2px}--> </style> <script type= "text/ JavaScript ' > Function Scrolldoor () {} Scrolldoor.prototype = {sd:function (menus,divs,openclass,closeclass) {var _th is = this; if (menus.length!= divs.length) {alert ("The number of menu layers and content layers is not the same!"); return false;} for (var i = 0; i < menus.length; i++) {_ this.$ (Menus[i]). value = i; _this.$ (Menus[i]). onmouseover = function () {for (var j = 0; J < Menus.length; J + +) {_this.$ (menus[j)). ClassName = Clo Seclass; _this.$ (Divs[j]). Style.display = "none"; } _this.$ (Menus[this.value]). ClassName = Openclass; _this.$ (Divs[this.value]). style.display = "block"; }}, $: function (OID) {if (typeof (OID) = "string") return document.getElementById (OID); Window.onload = function () {var sdmodel = new Scrolldoor (); SDMODEL.SD (["M01", "m02", "M03", "M04", "M05"],["C01", "C02", "c03", "C04", "C05"], "sd01", "sd02"); SDMODEL.SD (["Mm01", "mm02", "Mm03", "mm04", "mm05"],["cc01", "Cc02", "cc03", "CC04", "CC05"], "sd01", "sd02"); SDMODEL.SD (["Mmm01", "mmm02", "Mmm03", "mmm04", "mmm05"],["ccc01", "Ccc02", "ccc03", "CCC04", "CCC05"], "sd01", "sd02"); </script> </pead> <body> <div class= "Bodyer" > <p class= "t_rt" > Sliding door Encapsulation Class </p> < H2> Effect Preview </p> <div class= "Preview" > <div class= "scrolldoorframe" > <ul class= "Scrollul" > <li class= "sd01" id= "m01" > Sliding door </li> <li class= "sd02" id= "m02" > Sliding door </li> <li class= "sd02" id= " M03 "> Sliding door </li> <li class=" sd02 "id=" m04 "> Sliding door </li> <li class= "sd02" id= "m05" > Sliding door </li> </ul> <div class= "bor03 cont" > <div id= "C01" > First level content </div> <div id= "C02" class= "hidden" > Second layer content </div> <div id= "c03" class= "hidden" > Third layer Content </ div> <div id= "C04" class= "hidden" > Fourth layer </div> <div id= "c05" class= "hidden" > Fifth level content </div> ;/div> </div> </div> <div class= "Preview" > <div class= "scrolldoorframe" > <ul class= " Scrollul "> <li class=" sd01 "id=" mm01 "> Sliding door </li> <li class=" sd02 "id=" mm02 "> Sliding door </li> <li class= "sd02" id= "mm03" > Sliding door </li> <li class= "sd02" id= "mm04" > Sliding door </li> <li class= "sd02" id= "mm05" "> Sliding door </li> </ul> <div class=" bor03 cont "> <div id=" CC01 "> First level content </div> <div id=" Cc02 "Class=" hidden > second-level content </div> <div id= "cc03" class= "hidden" > The third Level content </div> <div id= "CC04" class= " Hidden "> Fourth layer </div> <div id=" CC05 "Class= "hidden" > Fifth level </div> </div> </div> </div> <div class= "Preview" > <div class= " Scrolldoorframe "> <ul class=" Scrollul "> <li class=" sd01 "id=" mmm01 "> Sliding door </li> <li class=" SD02 " Id= "mmm02" > Sliding door </li> <li class= "sd02" id= "mmm03" > Sliding door </li> <li class= "sd02" id= "mmm04" > Sliding door </li> <li class= "sd02" id= "mmm05" > Sliding door </li> </ul> <div class= "bor03 cont" > <div id= " CCC01 "> First layer content </div> <div id=" Ccc02 "class=" hidden "> Second level content </div> <div id=" ccc03 "class=" hidden " > Third content </div> <div id= "CCC04" class= "hidden" > Fourth level content </div> <div id= "ccc05" class= "hidden" > V Layer content </div> </div> </div> </div> </div> </body> </ptml>
[Ctrl + A ALL SELECT hint: You can modify some of the code, and then run]

1. Introduce the above code to your page <script type= "Text/javascript" src= "Scrolldoor.js" ></script>

2. Add the following code before the "<body>" tab of the page:


<script type= "Text/javascript" >

var Sdmodel = new Scrolldoor ();

SDMODEL.SD ([menu ID array],[display layer ID array], "Menu Trigger Class", "Menu off Class");

SDMODEL.SD ([menu ID array 2],[display layer ID array 2], "Menu Trigger Class", "Menu off Class");

SDMODEL.SD ([menu ID array 3],[display layer ID array 3], "Menu Trigger Class", "Menu off Class");

</script>

The parameters in the SD method are:

parameter one [menu ID array]: ID of the Sliding door menu

Parameter two [content ID array]: Show and hide the ID of the sliding content layer

Parameter three "menu Trigger class": The mouse passes through the sliding door menu class

Parameter four "menu off class": Mouse slide out of sliding door menu class

3. There are several sliding doors on the page to call the SD function several times, just change the parameters of the SD call, as shown in the above code.



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.