60秒倒计时

<input type="button" id="btn" value="免费获取验证码" onclick="settime(this)" />

<script type="text/javascript">

var countdown=60;

function settime(val) {

if (countdown == 0) {

val.removeAttribute("disabled");

val.value = "免费获取验证码";

//countdown = 60 ;

} else {

val.setAttribute("disabled", true);

val.value="重新发送(" + countdown + ")";

countdown--;

}

setTimeout(function() { settime(val) },1000)

}

</script>

//js倒计时

<html>
<title> 倒计时效果 </title>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<script language="JavaScript">
 var TotalMinutes = 5;
 var TotalMilliSeconds = 5*60*1000;
    
 function takeCount()
 {
    //计数减一
    TotalMilliSeconds -= 1000;
    //计算时分秒
    var hours = Math.floor( TotalMilliSeconds / ( 1000 * 60 * 60 )) % 24;
    var minutes = Math.floor(TotalMilliSeconds / (1000 * 60)) % 60;
    var seconds = Math.floor(TotalMilliSeconds / 1000) % 60;
    //将时分秒插入到html中
    document.getElementById("RemainH").innerHTML = hours;
    document.getElementById("RemainM").innerHTML = minutes;
    document.getElementById("RemainS").innerHTML = seconds;  
 }
 
 window.onload = setInterval("takeCount();",1000);
</script>
</head>
<body>
<div id="CountMsg">
倒计时还有:
<strong id="RemainD"></strong><strong id="RemainH">XX</strong>时
<strong id="RemainM">XX</strong>分
<strong id="RemainS">XX</strong>秒
</div>
</body>
</html>

时间: 2024-12-28 14:10:27

60秒倒计时的相关文章

验证码60秒倒计时

验证码60秒倒计时(jQuery), 代码如下: //验证码倒计时 var countdown = 60; var st; function settime(element) { if (countdown != 0) { st = setTimeout(function () { settime(element); }, 1000); } if (countdown == 0) { element.removeAttr("disabled"); element.val("获

js jquery 按钮点击后 60秒之后才能点击 60秒倒计时

var wait = 60; function time(o) { if (wait == 0) { $(o).attr("disabled", false); $(o).val("获取验证码"); wait = 60; } else { $(o).attr("disabled", true); o.val(wait + "秒后重新发送"); wait--; setTimeout(function () {time(o);},

js实现60秒倒计时效果(使用了jQuery)

今天碰到要实现一个类似那种短信验证码60秒倒计时的需求,好久不写js,有点手生.把代码记录下,方便后续查阅. 这里我用了jQuey,毕竟写起来简洁点.下面直接看效果和代码. 一.效果 二.代码 (1)html <input type="button" id="btn" value="免费获取验证码" onclick="daojishi(10,this)" /> 注意:要引入JQuery (2)js <scri

yii框架实现注册页面短信验证60秒倒计时

先说下简单的,直接用jquery来实现短信验证60秒倒计时,然后在说明在yii框架下怎么实现的. <!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">

淘宝60秒倒计时

<!DOCTYPE html> <html> <head> <title>60秒倒计时</title> <script type="text/javascript"> window.onload=function(){ var oBtn = document.getElementById('but'); var conut = 60; var timer = null; oBtn.onclick=function(

点击按钮出现60秒倒计时js代码

<!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> <meta http-equiv="Content-

Jquery 插件防刷新 60秒倒计时

//先到官网(http://plugins.jQuery.com/cookie/)下载cookie插件,放到相应文件夹,代码如下: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <title>

jQuery实现发送短信验证码后60秒倒计时

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> var countdown=60; functi

60秒倒计时,自动跳转到指定页面

<script type="text/javascript" charset="utf-8"> //设定倒数秒数 var t = 60; //显示倒数秒数 function showTime(){ t -= 1; document.getElementById('jumpTo').innerHTML= t; if(t==0){ location.href='http://www.baidu.com'; } //每秒执行一次,showTime() setT