Javascript JS slidable Div Block

Source: Internet
Author: User

Slide Div blocks </P> <p> <! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en"> <br/> <HTML> <br/> <pead> <br/> <title> slide Div </title> </P> <p> <meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3 "> <br/> <meta http-equiv =" Description "content =" this is my page "> <br/> <meta http-equiv =" Content-Type" content = "text/html; charset = UTF-8 "> <br/> <SCRIPT type =" text/JavaScript "> <br/> var I = 0; <br/> var step = 2; <br/> var timed; <br/> var h = 0; // sliding height <br/> function slide () {<br/> timed = setTimeout ("slide ()", 10); <br/> var boxheight = document. getelementbyid ("obox "). style. height. replace ("PX", ""); // height of the outer Div <br/> var slideboxstyle = document. getelementbyid ("slidebox "). style; <br/> var Top = slideboxstyle. margintop. replace ("PX", ""); <br/> var slideboxheight = slideboxstyle. height. replace ("PX", ""); // sliding Div height <br/> var totalheight = Number (boxheight)-number (slideboxheight ); <br/> H = Number (top) + step; <br/> if (I <50 & H <= totalheight) {<br/> slideboxstyle. margintop = H + "PX"; <br/> I + = step; <br/>}else {<br/> cleartimeout (timed ); <br/> I = 0; <br/>}< br/> document. getelementbyid ("show "). value = H + ":" + totalheight; <br/>}< br/> </SCRIPT> </P> <p> </pead> </P> <p> <body> <br/> <Div id = "obox" style = "width: 100px; Height: 300px; Background-color: red; overflow: hidden "> <br/> <Div id =" slidebox "style =" width: 100px; Height: 100px; background-color: Gray; margin-top: 0px "> <br/> </div> <br/> <input type =" button "value =" Go... "onclick =" slide () "> <br/> <input type =" text "id =" show "> <br/> </body> <br/> </ptml> <br/>

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.