本文目录一览:
点击按钮出现60秒倒计时的简单js代码(推荐)
点击按钮出现60秒倒计时的简单js代码(推荐)
!DOCTYPE
html
PUBLIC
"-//W3C//DTD
XHTML
1.0
Transitional//EN"
""
html
xmlns=""
head
meta
http-equiv="Content-Type"
content="text/html;
charset=utf-8"
/
title点击按钮出现60秒倒计时的简单js代码(推荐)/title
script
type="text/javascript"
src="js/jquery.js"/script
/head
body
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
/body
/html
以上这篇点击按钮出现60秒倒计时的简单js代码(推荐)就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
JS 倒计时实现代码(时、分,秒)
JS实现倒计时(时、分,秒)
var
interval
=
1000;
function
ShowCountDown(year,month,day,divname)
{
var
now
=
new
Date();
var
endDate
=
new
Date(year,
month-1,
day);
var
leftTime=endDate.getTime()-now.getTime();
var
leftsecond
=
parseInt(leftTime/1000);
//var
day1=parseInt(leftsecond/(24*60*60*6));
var
day1=Math.floor(leftsecond/(60*60*24));
var
hour=Math.floor((leftsecond-day1*24*60*60)/3600);
var
minute=Math.floor((leftsecond-day1*24*60*60-hour*3600)/60);
var
second=Math.floor(leftsecond-day1*24*60*60-hour*3600-minute*60);
var
cc
=
document.getElementById(divname);
cc.innerHTML
=
"脚本之家提示距离"+year+"年"+month+"月"+day+"日还有:"+day1+"天"+hour+"小时"+minute+"分"+second+"秒";
}
window.setInterval(function(){ShowCountDown(2010,4,20,'divdown1');},
interval);
[Ctrl+A
全选
注:如需引入外部Js需刷新才能执行]
网页点击按钮开始一小时倒计时的JavaScript代码
!DOCTYPE html
html
head
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
title/title
script
var interval;
var djs = function(){
if(!!interval) return;
var d = new Date("1111/1/1,1:0:0");
result.innerHTML = d.getHours() + "时"
+ d.getMinutes() + "分" + d.getSeconds() + "秒";
interval = setInterval(function(){
if(d.getHours() ==0d.getMinutes()==0d.getSeconds()==0) {
clearInterval(interval);
interval =null;
}
result.innerHTML = d.getHours() + "时"
+ d.getMinutes() + "分" + d.getSeconds() + "秒";
d.setSeconds(d.getSeconds() - 1);
},1000);
}
/script
/head
body
div id="result"
/div
button onclick="djs()"
倒计时
/button
/body
/html