js操作属性,例题2.

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<input type="submit" name="button" id="button" disabled="disabled" value="提交" />
</body>
</html>
<script>
var n=10;
var a=document.getElementById("button") //获取id是button这个标签的值并赋给变量a
hanshu();  //调用函数
function hanshu()
{
    n--;   //n自减1
    if(n==0)  
    {
        a.removeAttribute("disabled") //当n是0的时候,移除这个属性
        a.value="同意";  //把属性改成同意
        return;       //把值返回给函数
        }
        else     //当a不是0的时候
        {
            a.value="慢慢来("+n+")";   //把属性改成慢慢来
            window.setTimeout("hanshu()",1000)  //一秒秒的显示
            }

    }
</script>

 

posted @ 2015-05-15 15:19  zhenximeiyitian  阅读(102)  评论(0编辑  收藏  举报