Examples of JS time control to achieve dynamic results and js instances

Source: Internet
Author: User

Examples of JS time control to achieve dynamic results and js instances

As follows:

<Script> BOM // Bowers Object Model: the Object Model of the browser setTimeout () // The setInterval () execution is delayed once. // The interval is var a = 300; window. setTimeout ('abc (a) ', 3000); // value assignment function abc (I) {alert (I) ;}// setInterval ('alert (123) ', 2000); var dh = document. getElementById ("dh"); // alert (dh. offsetLeft); function move () {dh. style. marginLeft = dh. offsetLeft + 1 + 'px ';} var x = window. setInterval ('move () ', 20); var y = window. setInterval ('move () ', 500); function clear () {window. clearInterval (x);} // execute window to clear the interval. setTimeout ("clear ()", 2500); // code to be executed; interval window. setInterval ('alert (123) ', 1000); </script> Use Time Control to perform clock operations <style> * {margin: 150px auto; width: 500px; height: 500px ;} </style> <body> <div> <span id = "h"> </span> <span id = "m"> </span> <span id = "s "> </span> </div> <script type =" text/javascript "> window. setInterval ("time ()", 1000); custom time function time () {Date and time function call var time = new Date (); document. getElementById ("h "). innerText = time. getHours () + ':'; document. getElementById ("m "). innerText = time. getMinutes () + ':'; document. getElementById ("s "). innerText = time. getSeconds () ;}</script> </body>

The example of the above JS time control to achieve dynamic results is all the content shared by Alibaba Cloud xiaobian. I hope to give you a reference and support for the customer's house.

Related Article

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.