js 倒计时点击和当前时间

<input id="btn" type="submit" value="确定" disabled="disabled" />
<span id="daojishi">10</span>
<script type="text/javascript">

window.setTimeout("YanChi()",1000);

function YanChi()
{
    var span = document.getElementById("daojishi");
    
    //改变span里面的值
    span.innerText = span.innerText-1;
    
    //判断是否减到了0
    if(span.innerText == 0)
    {
        document.getElementById("btn").removeAttribute("disabled");
        return;
    }
    
    window.setTimeout("YanChi()",1000);
    
}


</script>
View Code

倒计时

<div>
    <span id="h"></span>
    <span id="m"></span>
    <span id="s"></span>
</div>
<script type="text/javascript">

window.setInterval("Bian()",1000);

function Bian()
{
    var sj = new Date();
    
        document.getElementById("h").innerText = sj.getHours();
    document.getElementById("m").innerText = sj.getMinutes();
    document.getElementById("s").innerText = sj.getSeconds();
    
}

</script>
View Code

时间

原文地址:https://www.cnblogs.com/bilibiliganbei/p/5896962.html