简单地:
(function($){
$.fn.plugin = function()
{
// results in error
// when called like
// $.plugin();
}
})(jQuery);
错误是(从 Chrome 控制台复制):
Uncaught TypeError: Object function ( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context, rootjQuery );
} has no method 'plugin'
为了使我的插件在没有元素选择的情况下工作,我必须遵循哪些规则?