javascript倒计时
1 window.setInterval(function() {var DateOne=$("#hiddenDate").val();
2 var neMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));
3 var neDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);
4 var neYear = DateOne.substring(0,DateOne.indexOf ('-')); ShowCountDown('hello',neMonth,neDay,neYear); }, 1000);
5 function ShowCountDown(divname,neMonth,neDay,neYear) {
6 var now = new Date();
7 var endDate = new Date(neYear, neMonth-1, neDay, "23", "59", "59");
8 var leftTime = endDate.getTime() - now.getTime();
9 var leftsecond = parseInt(leftTime / 1000);
10 var day0 = parseInt(leftsecond / (24 * 60 * 60));
11 var day1 = Math.floor(leftsecond / (60 * 60 * 24));
12 var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600);
13 var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60);
14 var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60);
15
16 var cc = document.getElementById(divname);
17 cc.innerHTML="距离本期报名结束还有 <span class=fB red><span id=day>"+day0+"</span>天<span id=hour>"+hour+"</span>时<span id=mini>"+minute+"</span>分<span id=sec>"+second+"</span>秒</span><br>"
18 }
2 var neMonth = DateOne.substring(5,DateOne.lastIndexOf ('-'));
3 var neDay = DateOne.substring(DateOne.length,DateOne.lastIndexOf ('-')+1);
4 var neYear = DateOne.substring(0,DateOne.indexOf ('-')); ShowCountDown('hello',neMonth,neDay,neYear); }, 1000);
5 function ShowCountDown(divname,neMonth,neDay,neYear) {
6 var now = new Date();
7 var endDate = new Date(neYear, neMonth-1, neDay, "23", "59", "59");
8 var leftTime = endDate.getTime() - now.getTime();
9 var leftsecond = parseInt(leftTime / 1000);
10 var day0 = parseInt(leftsecond / (24 * 60 * 60));
11 var day1 = Math.floor(leftsecond / (60 * 60 * 24));
12 var hour = Math.floor((leftsecond - day1 * 24 * 60 * 60) / 3600);
13 var minute = Math.floor((leftsecond - day1 * 24 * 60 * 60 - hour * 3600) / 60);
14 var second = Math.floor(leftsecond - day1 * 24 * 60 * 60 - hour * 3600 - minute * 60);
15
16 var cc = document.getElementById(divname);
17 cc.innerHTML="距离本期报名结束还有 <span class=fB red><span id=day>"+day0+"</span>天<span id=hour>"+hour+"</span>时<span id=mini>"+minute+"</span>分<span id=sec>"+second+"</span>秒</span><br>"
18 }
1 <input type="hidden" id="hiddenDate" name="hiddenDate" value="2011-3-7">
2 <div id="hello"></div>
2 <div id="hello"></div>