标签:uri min number -o 实现 rop math 插件 -name
前面介绍了wordpress自定义样式倒计时插件jcountdown ,插件的话不受主题更换的影响,如何需要用代码实现的话,下面给大家分享不用插件如何实现倒计时功能。
第一步新增一个js文件 countdown.js,代码如下:
function ShowCountDown(prefix,year,month,day,hourd,minuted,seconded){
var now = new Date();
if( typeof(hourd) == "undefined" ) hourd=23;
if( typeof(minuted) == "undefined" ) minuted=59;
if( typeof(seconded) == "undefined" ) seconded=59;
var endDate = new Date(year, month-1, day, hourd, minuted,seconded);
var leftTime=endDate.getTime()-now.getTime();
var leftsecond = parseInt(leftTime/1000);
var day=Math.floor(leftsecond/(60*60*24));
day = day < 0 ? 0 : day;
var hour=Math.floor((leftsecond-day*24*60*60)/3600);
hour = hour < 0 ? 0 : hour;
var minute=Math.floor((leftsecond-day*24*60*60-hour*3600)/60);
minute = minute < 0 ? 0 : minute;
var second=Math.floor(leftsecond-day*24*60*60-hour*3600-minute*60);
second = second < 0 ? 0 : second;
//var day2 = (day<10?"0"+day:day);
var hour2 = (hour<10?"0"+hour:hour);
var minute2 = (minute<10?"0"+minute:minute);
var second2 = (second<10?"0"+second:second);
jQuery("#"+prefix+"_countDown_day").html(day);
jQuery("#"+prefix+"_countDown_hour").html(hour2);
jQuery("#"+prefix