js 30分钟倒计时

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        
        <div id="countdown">还剩 30 分 00 秒</div>

        <script>
                    
            window.onload=function(){
                var countdown=document.getElementById("countdown");
                
                var time=1800;//30分钟换算成1800秒
                 
                
                setInterval(function(){
                    time=time-1;
var minute=parseInt(time/60); var second=parseInt(time%60); countdown.innerHTML='还剩'+minute+''+second+''; },1000); } </script> </body> </html>
原文地址:https://www.cnblogs.com/pengc/p/8794038.html