Javascript adaptive height Tab

Source: Internet
Author: User

The specific JavaScript code is as follows: Copy codeThe Code is as follows: var getSiblingNode = function (className, elAr, el, not ){
ClassName = "" + className + "";
Var Arr = [];
For (var I = 0, l = elAr. length; I <l; I ++ ){
If (elAr [I]! = El & (elAr [I]. nodeType = 1) & ("" + elAr [I]. className + ""). indexOf (className)>-1 & not ){
Arr. push (elAr [I]);
}
Else if (elAr [I]! = El & elAr [I]. nodeType = 1 ){
Arr. push (elAr [I]);
}
}
Return Arr;
}
Var runFn = function (id, parentId ){
Var elId = id, parentId = parentId;
Var contentEl = document. getElementById (elId );
Var liEl = contentEl. getElementsByTagName ("ul") [0]. getElementsByTagName ("li ");
Var divEl = document. getElementById (parentId). getElementsByTagName ("div ");
For (var I = 0, l = liEl. length; I <l; I ++ ){
// A closure is provided to obtain similar elements of the selected element;
(Function (I ){
Var thisSibling = getSiblingNode ("n", divEl, divEl [I], true );
LiEl [I]. onclick = function (){
DivEl [I]. style. display = "block ";
// Set the status of the selected dom element;
This. className = "hasClick ";
Var divElSibling = getSiblingNode (null, liEl, liEl [I], false );
// Set the css of other unselected dom elements;
For (var a = 0, B = thisSibling. length; a <B; a ++ ){
ThisSibling [a]. style. display = "none ";
}
For (var x = 0, y = divElSibling. length; x <y; x ++ ){
DivElSibling [x]. className = "havtClick ";
}
}
}) (I)
}
}
Var slide = function (){
RunFn ("content", "disDiv ");
}
Window. onload = slide;

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.