function setTab(name,cursel,n){
for(i=1i<=ni++){
var menu=document.getElementById(name+i)
var con=document.getElementById("con_"+name+"_"+i)
menu.className=i==cursel?"hover":""
con.style.display=i==cursel?"block":"none"
}
}var DifferenceHour = -1
var DifferenceMinute = -1
var DifferenceSecond = -1
var Tday = new Date("Feb 14, 2010 00:00:00") //**倒计时时间点-注意格式
var daysms = 24 * 60 * 60 * 1000
var hoursms = 60 * 60 * 1000
var Secondms = 60 * 1000
var microsecond = 1000function left(mainStr,lngLen) {
if (lngLen>0) {return mainStr.substring(0,lngLen)}
else{return null}
}
function right(mainStr,lngLen) { if (mainStr.length-lngLen>=0 &&mainStr.length>=0 &&mainStr.length-lngLen<=mainStr.length) {
return mainStr.substring(mainStr.length-lngLen,mainStr.length)}
else{return null}
}
function mid(mainStr,starnum,endnum){
if (mainStr.length>=0){
return mainStr.substr(starnum,endnum)
}else{return null} }function clock()
{
var time = new Date()
var hour = time.getHours()
var minute = time.getMinutes()
var second = time.getSeconds()
var timevalue = ""+((hour >12) ? hour-12:hour)
timevalue +=((minute <10) ? ":0":":")+minute
timevalue +=((second <10) ? ":0":":")+second
timevalue +=((hour >12 ) ? " PM":" AM")var convertHour = DifferenceHour
var convertMinute = DifferenceMinute
var convertSecond = DifferenceSecond
var Diffms = Tday.getTime() - time.getTime()
DifferenceHour = Math.floor(Diffms / daysms)
Diffms -= DifferenceHour * daysms
DifferenceMinute = Math.floor(Diffms / hoursms)
Diffms -= DifferenceMinute * hoursms
DifferenceSecond = Math.floor(Diffms / Secondms)
Diffms -= DifferenceSecond * Secondms
var dSecs = Math.floor(Diffms / microsecond)var dd=document.getElementById("dd")
var hh=document.getElementById("hh")
var mm=document.getElementById("mm")
var ss=document.getElementById("ss")ddstr = DifferenceHour.toString()
hhstr = DifferenceMinute.toString()
mmstr = DifferenceSecond.toString()
ssstr = dSecs.toString()if (Tday.getTime() >time.getTime()){
if (ddstr.length<2){
ddstrs = "<span class='num0'></span><span class='num"+ddstr.substr(0,1)+"'></span>"
}else{
ddstrs = "<span class='num"+ddstr.substr(0,1)+"'></span><span class='num"+ddstr.substr(1,2)+"'></span>"
}if (hhstr.length<2){
hhstrs = "<span class='num0'></span><span class='num"+hhstr.substr(0,1)+"'></span>"
}else{
hhstrs = "<span class='num"+hhstr.substr(0,1)+"'></span><span class='num"+hhstr.substr(1,2)+"'></span>"
}if (mmstr.length<2){
mmstrs = "<span class='num0'></span><span class='num"+mmstr.substr(0,1)+"'></span>"
}else{
mmstrs = "<span class='num"+mmstr.substr(0,1)+"'></span><span class='num"+mmstr.substr(1,2)+"'></span>"
}if (ssstr.length<2){
ssstrs = "<span class='num0'></span><span class='num"+mmstr.substr(0,1)+"'></span>"
}else{
ssstrs = "<span class='num"+ssstr.substr(0,1)+"'></span><span class='num"+ssstr.substr(1,2)+"'></span>"
}
}else{
ddstrs="<span class='num0'></span><span class='num0'></span>"
hhstrs="<span class='num0'></span><span class='num0'></span>"
mmstrs="<span class='num0'></span><span class='num0'></span>"
ssstrs="<span class='num0'></span><span class='num0'></span>"
}if(convertHour != DifferenceHour) dd.innerHTML=ddstrs
if(convertMinute != DifferenceMinute) hh.innerHTML=hhstrs
if(convertSecond != DifferenceSecond) mm.innerHTML=mmstrs
ss.innerHTML=ssstrs
setTimeout("clock()",1000)}</script>上面的是JS部分的。 下面是HTML部分的。<div class="mains">
<div class="djs">
<div id="dd"></div>
<div id="tsfm">天</div>
<div id="hh"></div>
<div id="tsfm">时</div>
<div id="mm"></div>
<div id="tsfm">分</div>
<div id="ss"></div>
<div id="tsfm">秒</div>
</div>我上面的JS部分的数字全部是用的图片格式显示倒计时数字的哈,你也可以自己改成数字。 好了,上面的代码全部是我之前给客户写的一个春节倒计时贺卡的程序页面,纯原创,并且一直在用,所以是没有任何问题的,你自己应该懂一些技术吧,所以上面的代码你应该看的懂,很简单的。 就不要再追问了,自己多下下功夫研究下,因为最近比较忙,不见得有时间回复,见谅。记得给我分哈,要升级这个号的级别,以后好推广用,谢谢了。
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html charset=utf-8" />
<title>js实现倒计时60秒的简单代码(推荐)</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 = 5
} else {
val.setAttribute("disabled", true)
val.value="重新发送(" + countdown + ")"
countdown--
setTimeout(function() {
settime(val)
},1000)
}
}
</script>
</body>
</html>
JavaScript简介
JavaScript 是脚本语言
JavaScript 是一种轻量级的编程语言。
JavaScript 是可插入 HTML 页面的编程代码。
JavaScript 插入 HTML 页面后,可由所有的现代浏览器执行。
JavaScript 课外书
如果 JavaScript 教程学习完毕,并且需要更深入地学习这门语言,《JavaScript 高级教程》绝对是您最好的选择。本教程从 JavaScript 的历史开始讲起,直到当前它对 XML 和 Web 服务的支持。
将学习到如何扩展该语言,以使它适应特殊的需求。
还将学到如何使用 JavaScript 创建无缝的客户机 - 服务器通信。
欢迎分享,转载请注明来源:夏雨云
评论列表(0条)