JS代码
<script type="text/javascript" src="jquery-1.8.3.min.js"></script> <script type="text/javascript"> $(document).ready(function() { var times = 60 * 100; // 60秒 countTime = setInterval(function() { times = --times < 0 ? 0 : times; var ms = Math.floor(times / 100).toString(); if(ms.length <= 1) { ms = "0" + ms; } var hm = Math.floor(times % 100).toString(); if(hm.length <= 1) { hm = "0" + hm; } if(times == 0) { alert("游戏结束"); clearInterval(countTime); } // 获取分钟、毫秒数 $(".a").html(ms); $(".b").html(hm); }, 10); }); </script>