当时间接近零时,通过改变计时器的颜色或动画通知用户



我使用jQuery Countdown Timer & Digital Clock Plugin创建一个倒数计时器,如下所示:

<html>
<head>
    <link rel="stylesheet" type="text/css" href="timeTo.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">
        < script src = "jquery.timeTo.js" >
    </script>
    <script src="jquery.timeTo.min.js"></script>
    <script>
        var timeval = 60;
        var timeval = 60;
        $(document).ready(function() {
            $('#countdown').timeTo({
                seconds: timeval,
                displayHours: false
            });
        });
    </script>
</head>
<body>
    <div id="countdown"></div>
</body>
</html>

我需要改变定时器的颜色为红色,如果时间<5秒平均值接近零。为了通知用户时间即将结束。

也想重定向到另一个页面,一旦它达到零

请查看API链接

请指导我怎么做?

您可以按照以下要求使用countdownAlertLimit: 5:

var timeval = 60;
$('#countdown').timeTo({ seconds: timeval, displayHours: false, countdownAlertLimit: 5 });

还注意,如果你想重定向到另一个页面,你可以使用这行代码:

var timeval = 60;
$('#countdown').timeTo({ seconds: timeval, displayHours: false,   countdownAlertLimit: 5,callback:function(){
window.location="your location"
} });

当计时器达到5时,计时器将变为红色。

希望对你有帮助

也许这就是您正在寻找的。如果我没理解错的话,这已经是你想要的方式了!

http://lexxus.github.io/jq-timeTo/

最新更新