87,920
社区成员
发帖
与我相关
我的任务
分享
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
var time=30;
$("#cooldown").html(time+"s");
var t=setInterval(function(){
$("#cooldown").html(time+"s");
time--;
if(time==-1){
var v=$("#w").val(); //获得文本框里的值,判断
if(v!=""){
alert(v);
clearInterval(t); //清除定时器 停留在当前页
}else{
window.location="w.html"; //如果没操作(我用文本框代替),就跳转
}
}
},1000);
});
</script>
<style type="text/css">
</style>
</head>
<body>
<!--倒计时-->
<div id="btnSubmit" style="font-size:22px; color:#F03;">倒计时<span id="cooldown"></span>
</div>
<div>
<textarea style="width:100px; height:80px;" id="w"></textarea>
</div>
</body>
var coolDownTime = 30;//定义一个变量
var timer;/////计时器句柄
var coolDown = {
autoTime: function () {
//倒计时的方法
if (coolDownTime > 0) {
coolDownTime--;
$("#cooldown").html("\u300c" + coolDownTime + "\u300d");
} else {
//////////记住计时器
timer= setTimeout("coolDown.returnLoginPage()", 1000);
}
},
returnLoginPage: function () {
//关闭按钮的方法
$("#fullbg,#dialog").hide();
}
};
document.onmousemove = document.onclick = function () {
clearTimeout(timer);//有操作,清除计时器
}