倒计时
html
<p class="time" id="countdown">
<span id="days"></span><b>天</b><span id="hours"></span><b>小时</b><span id="minutes"></span><b>分钟</b><span id="seconds"></span><b>秒</b>
</p>
js
<script src="__TMPL__Mobile/js/jquery.countdown.min.js"></script>
<script type="text/javascript">
$(function(){
// 倒计时------
/* Counter */
var finished = false;
var countNum = $('#countNum').html();
// alert(countNum);
console.log(countNum);
// 时间格式:2017/02/08 20:50:00
var toDate = new Date(countNum); // Counter end date/time.
function callback(event) {
$this = $(this);
switch(event.type) {
case "seconds":
case "minutes":
case "hours":
case "days":
case "weeks":
case "daysLeft":
$this.find('span#'+event.type).html(event.value);
if(finished) {
$this.fadeTo(0, 1);
finished = false;
}
break;
case "finished":
$this.fadeTo('slow', .8);
finished = true;
break;
}
}
$('#countdown').countdown(toDate, callback);
});