1
我要调用此函数(使元素闪烁),声明为一个单独的文件:
(function($) {
$.fn.cyclicFade = function(options)
{
if (typeof(options) == 'string') {
if (options=='stop') {
$(this).stop(true);
return this.each(function() {
$(this).data('cyclic-fade').enabled = false;
});
}
else return null;
}
else {
var opts = $.extend({}, $.fn.cyclicFade.defaults, options);
return this.each(function() {
$(this).data('cyclic-fade', {enabled : true});
$.fn.cyclicFade.doCycle(this,1,opts.repeat,opts.params,0);
});
}
};
}
(它不是完整的,空间问题)
当我点击一个名为.swatch的div。我如何invoque该功能?
$(document).ready(function() {
$(".swatch").click(function() {
// .swatch starts to blink
});
});
在此先感谢。
还要提到的是`$ .fn.pluginName`使得pluginName jQuery对象的扩展 – mVChr 2011-02-07 18:41:56