1.用jquery實現時間計時器,從之前的某個時間段到現在距離多少天多少時多少分多少秒? html代碼: 複製程式碼 程式碼如下: 距離現在時間: 天 時 分 秒 <BR>$(function(){ <br><br>show_time(); <br><br>}); <br>show_time(); <br><BR>}); <BR>show_time(); <BR><BR>}); <BR>show_time(); <BR><BR>}); <BR>show_time(); <br><br>}); <BR>show_time(); <br><br>}); <BR><br>function show_time(){ <br>var time_start = new Date("2013/10/01 00:00:00").getTime();//設定開始時間<BR>var time_end = new Date ().getTime(); //設定結束時間(等於系統目前時間) <BR>//計算時間差<BR>var time_distance = time_end - time_start; <BR>if(time_distance > 0){ <BR>/ / 天時分秒換算<BR>var int_day = Math.floor(time_distance/86400000) <BR>time_distance -= int_day * 86400000; <BR><BR>var int_hour = Mathooroor000; <BR><BR>var int_hour = -= int_hour * 3600000; <BR><BR>var int_minute = Math.floor(time_distance/60000) <BR>time_distance -= int_minute * 60000 <BR>// 時分秒為單數時、前面加零<BR>if(int_day < 10){ <BR>int_day = "0" int_day; <BR>} <br>if(int_hour < 10){ <br>int_hour = "0" int_hour; <br>} <br>if(int_minute < 10){ <BR>int_minute = "0" int_minute; <BR>} <BR>if(int_second < 10){ <seconds> = "0" int_second; <BR>} <br>// 顯示時間<br>$("#time_d").html(int_day); <BR>$("#time_h").html(int_hour); <BR>$("#time_m").html(int_minute); <BR>$("#time_s").html(int_second); <🎜>setTimeout("show_time()",1000); <🎜 ><🎜>}else{ <🎜>$("#time_d").html('00'); <🎜>$("#time_h").html('00'); <🎜>$("# time_m").html('00'); <🎜>$("#time_s").html('00'); <🎜><🎜>} <🎜>} <🎜>