<!DOCTYPE HTML> <html> <head> <meta charset="UTF-8" /> <title>pro.html</title> <style type="text/css"> </style> <script> var x = 30, interval; window.onload = function() { var d = new Date("1111/1/1,0:" + x + ":0"); interval = setInterval(function() { var m = d.getMinutes(); var s = d.getSeconds(); m = m < 10 ? "0" + m : m; s = s < 10 ? "0" + s : s; btn.innerHTML = m + ":" + s; if (m == 0 && s == 0) { clearInterval(interval); return; } d.setSeconds(s - 1); }, 1000); } </script> </head> <body> <div id="btn"></div> </body> </html>