js练习1(十秒钟阅读效果)

<html>
    <head>
        <title>10秒钟阅读协议效果</title>
    </head>
    <body>
        <input type="button" name="btn" value=""  id="btn"  />
        <script>
            var n=10;
            var time;
            var b=document.getElementById("btn");
            b.disabled=true;
            b.style.width=50;
            
            function change(){
                b.value=n;
                n--;
                if(n<0){
                    b.value="同意";
                    b.disabled=false;
                    clearInterval(time);
                }
            }
            time=setInterval("change()",1000);
        </script>
    </body>
</html>

 

你可能感兴趣的:(js)