简单的jQuery倒计时
jopen
10年前
<script type="text/javascript"> var timeIndex = 100;//总的分钟数 $(document).ready(function(){ var regex = /dateTime=(\d+)/; setTime(); setInterval(setTime, 1000);//每秒执行一次 }); function setTime(){ var hour = parseInt(timeIndex / 3600); var minutes = parseInt((timeIndex % 3600) / 60); var seconds = parseInt(timeIndex % 60); hour = hour < 10 ? "0" + hour : hour; minutes = minutes < 10 ? "0" + minutes : minutes; seconds = seconds < 10 ? "0" + seconds : seconds; $("#divTime").text(hour + ":" + minutes + ":" + seconds); if(timeIndex>0){ timeIndex--; } $("#linkTime").attr("href", url + timeIndex); }