【发布时间】:2011-07-08 22:38:52
【问题描述】:
假设这是我的插件:
// writing the plugin
(function($){
$.fn.myPlugIn = function(options){
defaults = {
beforeAnimate : function(){},
afterAnimate : function(){}
}
options = $.extend(defaults, options);
//here is where I need help
options.beforeAnimate();
$(this).animate({'width':'1000px'},1000);
options.afterAnimate();
}
})(jQuery);
//using the plugin
$('#art2').myPlugIn({
beforeAnimate: function(){
$('#art1').animate({'width':'1000px'},1000);
},
afterAnimate: function(){
$('#art3').animate({'width':'1000px'},1000);
}
});
我应该如何重写这部分:
options.beforeAnimate();
$(this).animate({'width':'1000px'},1000);
options.afterAnimate();
为了依次获得 3 个动画调用。 (即等待前一个完成)
【问题讨论】:
标签: javascript jquery jquery-plugins callback closures