标签:style blog http io ar color sp java on
1.距离倒计时;
2.跳转倒计时;
demo:
<html> <head> <meta charset="utf-8"/> <script src="jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ setInterval(function(){ $(".app_lj1").each(function(){ var Obj = this; var EndTime = new Date(parseInt($(Obj).attr(‘value‘)) * 1000); var NowTime = new Date(); var nMS=EndTime.getTime() - NowTime.getTime(); var nD=Math.floor(nMS/(1000 * 60 * 60 * 24)); var nH=Math.floor(nMS/(1000*60*60)) % 24; var nM=Math.floor(nMS/(1000*60)) % 60; var nS=Math.floor(nMS/1000) % 60; if(nS<10){ var nS=‘0‘+nS; } if(nM<10){ var nM=‘0‘+nM; } if(nD>= 0){ var str =(nH+nD*24)+‘:‘+nM+‘:‘+nS; $(Obj).html(str); $(Obj).css(‘color‘,‘red‘); } }); }, 100); }); </script> <script type="text/javascript"> var t = 300; function countDown(){ var time = document.getElementById("time"); t--; time.value=t; if (t<=0) { location.href="http://baidu.com"; clearInterval(inter); }; } var inter = setInterval("countDown()",1000); </script> </head> <body> 距离xx倒计时:<a class="ljlh1 app_lj1" value="1451491200"></a><br /> <input type="text" readonly="true" value="300" id="time" size="2px" style="font-size:16px"/></b>秒后自动跳至... </body> </html>
标签:style blog http io ar color sp java on
原文地址:http://www.cnblogs.com/ItcastZc/p/4121130.html