首页 > 代码库 > 过一定时间显示可用控件

过一定时间显示可用控件

 

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript">
        var time = 10;//指定要过多长时间
        function tranform()
        {    
            var btnagree = window.document.getElementById("IDagree");
            if (time > 0)
            {//在disabled的情况下继续操作控件,让他显示倒计时
                btnagree.value = "http://www.mamicode.com/同意(" + time + "s后继续)";
                time--;
            }
            else {
                btnagree.value = "http://www.mamicode.com/同意";

           //够时间的情况下,要把控件的可用性打开
                btnagree.disabled = false;

//清除时间循环
                clearInterval("timeID");        
            }
        }
        var timeID = setInterval("tranform()", 1000);
    </script>
</head>
<body onl oad="tranform()">

//开始让控件不可用
    <input id="IDagree" type="button" value="http://www.mamicode.com/同意" disabled="disabled" />
</body>
</html>