首页 > Web开发 > 详细

JQuery实现倒计时效果

时间:2014-02-28 03:33:20      阅读:578      评论:0      收藏:0      [点我收藏+]

首先:引入jquery文件

1
<script type="text/javascript" src="http://www.cnblogs.com/Content/Phone/js/Answer.js?201402242021"></script>

 

然后写javascript代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<script type="text/javascript">
 
    $(function () {
        timer;
    })
    var maxtime = 20 * 100;
    function CountDown() {
        if (maxtime >= 0) {
            seconds = Math.floor(maxtime / 100);
            milliseconds = Math.floor(maxtime % 100);
            seconds = seconds < 10 ? ("0" + seconds) : seconds;
            milliseconds = milliseconds < 10 ? ("0" + milliseconds) : milliseconds;
            $(".time").text(seconds + ":" + milliseconds);
            //if(maxtime == 5*60) alert(‘注意,还有5分钟!‘);
            if (maxtime == 270) {
                //$("#musicNear")[0].play();
            }
            maxtime -= 10;
        }
    }
 
    timer = window.setInterval(CountDown, 100);
</script>

 

 

JQuery实现倒计时效果,布布扣,bubuko.com

JQuery实现倒计时效果

原文:http://www.cnblogs.com/qiailu/p/3570864.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!