先看看我们的效果图片如下
下面看jquery+js的代码,我们这里不提供jquery库文件下载,大家可以官网去下载
代码如下 | 复制代码 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <title>翻页倒计时</title> <script src="jquery.js" type="text/javascript" charset="utf-8"></script> <script src="jquery.countdown.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> jQuery(function($) { $('#counter').countdown({ image: 'img/digits.png', startTime: '01:12:12:00' }); $('#counter_2').countdown({ <div id="counter"></div> |
jquery.countdown.js
代码如下 | 复制代码 |
jQuery.fn.countdown = function(userOptions) { // Default options var options = { stepTime: 60, format: "dd:hh:mm:ss", startTime: "01:12:32:55", digitImages: 6, digitWidth: 53, digitHeight: 77, timerEnd: function() {}, image: "digits.png" }; var digits = [], interval; var createDigits = function(where) { where.append(elem) var margin = function(elem, val, creat) { var moveStep = function(elem) { margin(elem, mtop); if (mtop == 0) digits[elem].__ismax = true; $.extend(options, userOptions); |