Preparing plugin for $.plugin() usage instead of $(selector).plugin()
jquery
Solution
Simply assign the function directly to `$.plugin`:
(function($){
$.plugin = function()
{
// ...
}
})(jQuery);
Of course `this` won't refer to selected elements anymore, but to `jQuery` itself.
Problem
Simply: ``` (function($){ $.fn.plugin = function() { // results in error // when called like // $.plugin(); } })(jQuery); ``` The error is (copied from Chrome console): ``` 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' ``` What rules I have to follow in order to make my plugin work without the element selection?