【发布时间】:2010-01-21 17:15:40
【问题描述】:
我写了一个带有以下“签名”的插件:
jQuery.fn.attach = function(element, settings, duration, options, callback) {
这里element是一个jQuery对象,settings是我的插件的自定义设置,duration、options和callback都是我在jQuery动画中使用的参数,像这样:
someObject.animate({ someCSS }, duration, options, callback);
现在,我的问题是:是否可以让这个函数更容易调用?例如,现在,为了让一切按我的预期工作......我必须包含所有参数并将我不使用的参数设置为null:
$(this).attach($('#e1-blue'), null, 3000, null, function() { alert('done'); });
如果也能够将其称为:
$(this).attach($('#e1-blue'), 3000, function() { alert('done'); });
并且作为这个(ofc)......
$(this).attach($('#e1-blue'), 3000);
有什么建议吗?
【问题讨论】:
标签: javascript jquery plugins jquery-plugins