六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 124|回复: 0

jquery倒计时插件

[复制链接]

升级  63.33%

39

主题

39

主题

39

主题

秀才

Rank: 2

积分
145
 楼主| 发表于 2013-2-7 23:40:28 | 显示全部楼层 |阅读模式
调用方法:
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><!--http://www.cssrain.cn/demo/jquery-ui-tab/jquery-1.3.1.js--><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <script src="jquery-1.4.2.js" type="text/javascript"></script><script src="time.js" type="text/javascript"></script><script>$(function(){/*****  测试1  ****/// 开始 && 重新开始$("#start").click(function(){$("#test").CRcountDown({startNumber:15,callBack:test}).css("color","red");});// 暂停$("#pause").click(function(){$("#test").pause();});// 暂停后 重新开始$("#again").click(function(){$("#test").reStart();});function test(){$("<p>1</p>")  .hide()  .fadeIn(1000)  .appendTo("body");}/*****  测试2  ****/// 开始 && 重新开始$("#start2").click(function(){$("#test2").CRcountDown({startNumber:10,callBack:test2}).css("color","blue");});// 暂停$("#pause2").click(function(){$("#test2").pause();});// 暂停后 重新开始$("#again2").click(function(){$("#test2").reStart();});function test2(){$("<p>2</p>")  .hide()  .fadeIn(1000)  .appendTo("body");}})</script></head><body><h1>测试1:</h1><button id="start" >开始&&重新开始</button><button id="pause" >暂停</button><button id="again" >暂停后 重新开始</button><div id="test" ></div><br/><h1>测试2:</h1><button id="start2" >开始&&重新开始</button><button id="pause2" >暂停</button><button id="again2" >暂停后 重新开始</button><div id="test2" ></div><br/><br/>Dev by cssrain</body></html> 
 
time.js的代码:
$(function(){jQuery.fn.countDown = function(settings,to) {if(!to && to != settings.endNumber) { to = settings.startNumber; }this.data("CR_currentTime",to);$(this).text(to).animate({"none":"none"},settings.duration,'',function() {if(to > settings.endNumber + 1) {$(this).countDown(settings,to - 1);}else{settings.callBack(this);}});return this;};//计时&&重新计时jQuery.fn.CRcountDown = function(settings) {settings = jQuery.extend({startNumber: 10,endNumber: 0,duration: 1000,callBack: function() { }}, settings);this.data("CR_duration",settings.duration);this.data("CR_endNumber",settings.endNumber);this.data("CR_callBack",settings.callBack);return this.stop().countDown(settings);};//计时暂停jQuery.fn.pause = function(settings) {return this.stop();};//暂停后,重新开始jQuery.fn.reStart = function() {return this.pause().CRcountDown({startNumber : this.data("CR_currentTime"),duration : this.data("CR_duration"),endNumber : this.data("CR_endNumber"),callBack : this.data("CR_callBack")});};}) 
 
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表