Timer-block Move

Source: Internet
Author: User

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3 <Head>4     <MetaCharSet= "UTF-8">5     <title>Document</title>6     <style>7     *{margin:0;padding:0;}8 #con{width:100px;Height:100px;background:Red;position:Absolute; Left:0;Top:100px;}9 #but{width:30px;Height:30px;}Ten  One     </style> A </Head> - <Body> -     <inputID= "but"type= "button"value= "Go"> the     <inputID= "BUT1"type= "button"value= "Stop"> -     <DivID= "Con"></Div> -      -     <Script> +     /*function as () { - alert (' AA '); +     }; A setinterval (as,100)*/ at     varCon=document.getElementById ('Con'); -     var but=document.getElementById (' but'); -     varBUT1=document.getElementById ('BUT1'); -     varL=0; -     varTimer=NULL, Time2=NULL, Time3=NULL; - But.onclick=function() { in clearinterval (timer); -         //clear the Timer every time you click, and then execute it to prevent the page from being triggered by multiple timers . to Timer=SetInterval (function() { + L+=Ten; - Con.style.left=L+'px'; the         }, -) *     }; $ But1.onclick=function() {Panax Notoginseng clearinterval (timer); -     }; the     //time2=settimeout (function () { +     //alert (' AA '); A     //},1000) the //Timeout timer can be used as a delay effect. +     </Script> - </Body> $ </HTML>
View Code

Timer-block Move

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.