Implement the countdown function (setInterval, clearInterval) and setinterval in html

Source: Internet
Author: User

Implement the countdown function (setInterval, clearInterval) and setinterval in html

Key points used for countdown: 1. setInterval for setting the time interval can be canceled by clearInterval

2. millisecond conversion to time format

This is

Below are functions in js

Var shi jian = 3600; var time = null; function start () {time = setInterval ("count ()", 1000 ); // return value time only for clearInterval (time) clearing time interval when paused} function count () {if (shijian <0) {alert ("time out "); pause (); // in general, this if condition is used to submit data. Here we just test it. } Else {$ ("# time p" ).html (Math. floor (shijian/60) + ":" + shijian % 60); // here, the time format of converting milliseconds is shijian --; lele.info (time) ;}} function pause () {clearInterval (time) ;}function goOn () {time = setInterval ("count ()", 1000); // reset the time interval}

The second is html resources. For convenience, css is directly written in html.

<! Doctype html> 

You can download the code by yourself.

Links: http://pan.baidu.com/s/1boZ8Xun password: ymu0

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.