一款简单美观的jQuery秒倒计时代码,精确到毫秒,自定义时间秒数点击开始按钮开始倒计时,点击重置按钮重新开始。
js代码
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
function timeout(obj){
if(obj<10){
}else{
var times = obj * 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);
}
}
$(function () {
$('.start').click(function () {
var a = $('.a').html();
timeout(a);
})
$('.end').click(function () {
$('.a').html(10);
$('.b').html('00');
clearInterval(countTime);
})
})
</script>
系统已开启自动识别垃圾评论机制,识别到的自动封号,下载出错或者资源有问题请联系全栈客服QQ 1915635791