jquery 倒计时效果实现秒杀的思路与代码
本文导语: jquery倒计时效果实现秒杀,代码如下: 代码示例: /** * 倒计时 秒杀 * by www. */ $(function(){ countDown("2015/9/8 11:11:59","#colockbox1"); }); function countDown(time,id){ var day_elem = $(id).find('.day'); var hour_elem = $(id).find('.hour'); var minut...
jquery倒计时效果实现秒杀,代码如下:
/**
* 倒计时 秒杀
* by www.
*/
$(function(){
countDown("2015/9/8 11:11:59","#colockbox1");
});
function countDown(time,id){
var day_elem = $(id).find('.day');
var hour_elem = $(id).find('.hour');
var minute_elem = $(id).find('.minute');
var second_elem = $(id).find('.second');
//if(typeof end_time == "string")
var end_time = new Date(time).getTime(),//月份是实际月份-1
sys_second = (end_time-new Date().getTime())/1000;
var timer = setInterval(function(){
if (sys_second > 1) {
sys_second -= 1;
var day = Math.floor((sys_second / 3600) / 24);
var hour = Math.floor((sys_second / 3600) % 24);
var minute = Math.floor((sys_second / 60) % 60);
var second = Math.floor(sys_second % 60);
day_elem && $(day_elem).text(day);//计算天
$(hour_elem).text(hour 您可能感兴趣的文章:
点击按钮 倒计时60秒方可再次点击发送的Js代码
Jquery实现团购倒计时的代码