JS倒计时执行操作

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    //换成你的jquery库
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
        var setTime;
        $(document).ready(function(){
            var time=parseInt($("#time").text());
            setTime=setInterval(function(){
                if(time<=0){
                    clearInterval(setTime);
                    return;
                }
                time--;
                $("#time").text(time);
            },1000);
        });
    </script>
</head>
<body>
    <span id="time">60</span>
</body>
</html>

 

posted @ 2016-11-25 17:26  God丶魔多  阅读(1594)  评论(0编辑  收藏  举报