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?
Simply assign the function directly to
$.plugin:Of course
thiswon’t refer to selected elements anymore, but tojQueryitself.