Jquery实现倒计后可操作

来源:互联网 发布:pandomo磐多魔 知乎 编辑:程序博客网 时间:2024/05/29 14:40
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <title>无标题页</title> 
    <script src="../js/jquery-1.4.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        var time=9;
        var intervalId;
        $(function(){ 
            intervalId=setInterval("init()",1000); 
        });
        function init(){
            time--;
            if(time>=0){
                $("#sub").attr("disabled",true);
                $("#sub").val("倒计时"+time+"秒"); 
            }
            else{
                $("#sub").attr("disabled",false);
                $("#sub").val("确认提交"); 
                clearInterval(intervalId);
            }
        } 
    </script>

</head>
<body>
    <input type="text" value="请仔细阅读条款,点击确定提交信息!"  />
    <input type="button" value="确认提交"  id="sub" disabled="disabled"/>
</body>
</html>
0 0
原创粉丝点击