jQuery 插件代码(收集)
2013-10-19 00:33
239 查看
为jQuery扩展wait方法 [jquery1.4之后添加该方法,但不同版本有不一样的写法]
<!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"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gbk" /> <title>Wait插件演示</title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script> <style type="text/css"> div { margin:3px; width:40px; height:40px; position:absolute; left:0px; top:30px; background:green; } </style> </head> <body> <div></div> <script type="text/javascript">//<![CDATA[ $.fn.extend({ wait: function(time, type) { return this.queue(type || "fx", function() { var $this = $(this); setTimeout(function() {$this.dequeue();}, time || 1000); }); } }); (function () { $("div").wait() .animate({left:'+=200'},2000) .wait() .animate({left:'-=200'},1500, arguments.callee); })(); //]]></script> </body> </html>
View Code
jQuery.fn.delay
---1.4~1.6.4 function (time, type) { time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; type = type || "fx"; return this.queue(type, function () { var elem = this; setTimeout(function () { jQuery.dequeue(elem, type); }, time); }); } ---1.7.0以后 function (time, type) { time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; type = type || "fx"; return this.queue(type, function (next, hooks) { var timeout = setTimeout(next, time); hooks.stop = function () { clearTimeout(timeout); }; }); }
相关文章推荐
- [转载]收集30个新鲜惊艳的JQuery插件和教程(带演示代码)
- [转 载]收集30个新鲜惊艳的JQuery插件和教程(带演示代码)
- JQuery插件让图片旋转任意角度且代码极其简单
- 收集的35个 jQuery 小技巧/代码片段,可以帮你快速开发.
- 60个很实用的jQuery代码开发技巧收集
- JQuery之拖拽插件实现代码
- 【收藏】300多个jQuery插件 -(写更少的代码,做更多的事情)
- jQuery满意度星级评价插件特效代码分享
- 收集的35个 jQuery 小技巧/代码片段
- 基于jQuery的Tab选项框效果代码(插件)
- .10个最佳jQuery Lightbox效果插件收集
- jQuery+ajax实现实用的点赞插件代码
- jquery制作图标导航插件鼠标悬停放大显示特效代码
- 精心收集的jQuery常用的插件1000
- jQuery插件实现表格隔行变色及鼠标滑过高亮显示效果代码
- 【收藏】300多个jQuery插件 -(写更少的代码,做更多的事情)...
- jQuery插件开发代码
- 收集国外的14个图片放大编辑的jQuery插件
- 借牛人代码一用 , 加载数据: 结合Jquery插件获取Json数据----------jTemplates
- jQuery Validate表单验证插件实现代码