Accordion effects in JavaScript

Source: Internet
Author: User

<! DOCTYPE html>ul {List-Style:none}*{margin:0; padding:0;            } div {width:1150px;            height:400px;            margin:50px Auto;            border:1px solid red;        Overflow:hidden;            } div li {width:240px;            height:400px; float: Left; /*Background-image:url (images/1.jpg);*/} div ul {width:1300px; }    </style>//Find someone    varbox = document.getElementById ("box"); varUL = Box.children[0]; varLis =Ul.children; //looping through the LIS binding background map     for(vari = 0; i < lis.length; i++) {Lis[i].style.backgroundimage= "url (images/" + (i + 1) + ". jpg"); //To each Li registered mouse after the event mouse after the exclusiveLis[i].onmouseover =function () {            //kill everyone and let everyone's width gradually change to             for(varj = 0; J < Lis.length; J + +) {animate (Lis[j], {"width": 100}); }            //leaving me to make my width gradually becomeAnimate This, {"width": 800});    }; }    //Mouse away from box all Li widths are gradually changed toBox.onmouseout =function () {         for(vari = 0; i < lis.length; i++) {animate (Lis[i], {"Width": 240});    }    }; functionAnimate (obj, JSON) {clearinterval (Obj.timer); Obj.timer= SetInterval (function () {            //Let's assume that all the properties have reached the target at the end of the execution.            varFlag =true;  for(varKinchJSON) {                varLeader = parseint (GetStyle (obj, k)) | | 0; vartarget =Json[k]; varStep = (Target-leader)/10; Step= step > 0?Math.ceil (STEP): Math.floor (step); Leader= leader +step; OBJ.STYLE[K]= leader + "px"; //if (leader = = = target) {                //clearinterval (obj.timer);                //}Console.log ("code is still running"); if(Leader! =target) {Flag=false;//tells the tag that the current attribute is not yet reached                }            }            //if it's still true at this point, it really does get to the            if(flag) {clearinterval (Obj.timer); }        }, 15); }    //all properties reach target value to clear    functionGetStyle (obj, attr) {if(window.getComputedStyle) {returnwindow.getComputedStyle (obj,NULL) [attr]; } Else {            returnObj.currentstyle[attr]; }    }</script></body>

Accordion effects in JavaScript

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.