倒计时注册

<textarea cols="50" rows="15" name="code" class="javascript"> var lefttimes = 10; var intervalId; function CountDown() { var btnagree = document.getElementById("btnagree"); if (btnagree) {//当按钮加载完毕后 if (lefttimes == 0) { btnagree.value = "同意"; btnagree.disabled = false; clearInterval(intervalId); } else { btnagree.value = "请仔细阅读此协议(还有" + lefttimes + "秒)"; lefttimes--; } } } intervalId = setInterval("CountDown()", 1000); </textarea>

 

页面内容:

<textarea cols="50" rows="15" name="code" class="xhtml">&lt;input id="btnagree" type="button" value="同意" disabled="disabled" /&gt; </textarea>  

jquery版:

<textarea cols="50" rows="15" name="code" class="javascript"> var lefttime = 10; setInterval(function () { if (lefttime &lt;= 0) { $("#btnagree").attr("disabled", false); $("#btnagree").val("同意"); return; } else { $("#btnagree").attr("disabled", true); $("#btnagree").val("请仔细阅读本协议,还有" + lefttime + "秒"); lefttime--; } },1000); }); </textarea>

你可能感兴趣的:(function,input,button)