过一定时间显示可用控件

 

 

<!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 = "同意(" + time + "s后继续)";
                time--;
            }
            else {
                btnagree.value = "同意";

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

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

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

posted @ 2014-05-03 20:04  上官瑾文  阅读(125)  评论(0编辑  收藏  举报