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