一款jquery倒计时

时间:2014-09-04 19:36:20   收藏:0   阅读:225
    <script type="text/javascript">
        var timeIndex = 100;//总的分钟数
        $(document).ready(function(){
            var regex = /dateTime=(\d+)/;
            setTime();
            setInterval(setTime, 1000);//每秒执行一次
        });
        function setTime(){
            var hour = parseInt(timeIndex / 3600);
            var minutes = parseInt((timeIndex % 3600) / 60);
            var seconds = parseInt(timeIndex % 60);
            hour = hour < 10 ? "0" + hour : hour;
            minutes = minutes < 10 ? "0" + minutes : minutes;
            seconds = seconds < 10 ? "0" + seconds : seconds;
            $("#divTime").text(hour + ":" + minutes + ":" + seconds);
            if(timeIndex>0){
                timeIndex--;
            }
            $("#linkTime").attr("href", url + timeIndex);
        }
评论(0)
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!