首页 > 其他 > 详细

倒计时插件

时间:2016-09-30 15:30:01      阅读:185      评论:0      收藏:0      [点我收藏+]

总喜欢整理一些小的demo,整合成插件,以后就方便用啦!

按钮的倒计时插件,参数直接给到秒数就好!

<script type="text/javascript">

$(".btn").click(function(){
	$(this).countdown(60);
});


$.fn.extend({
	 countdown:function(seconds){
	 	var time=seconds;
		var timer;
		var _this=$(this);
		_this.addClass("on");
		_this.find("a").html("重新获取("+seconds+"s)");
		timer=setInterval(function(){
			time--;
			if(time<0){
				clearInterval(timer);
				_this.removeClass("on");
				_this.find("a").html("获取验证码");
				time=seconds;
			}else{
				_this.find("a").html("重新获取("+time+"s)");
			}
		},1000);
		 }

});


</script>

  

倒计时插件

原文:http://www.cnblogs.com/chaoli/p/5923539.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!