How to create jQuery functions? -
i have seen few different approaches create jquery(-namespaced) functions, cannot quite tell actual difference between them.
jquery.fn.myfunction = function() { ... };
jquery.myfunction = function() { ... };
jquery.fn.extend({ myfunction: function() { ... } });
jquery.fn.myfunction use create functions available on every jquery result set:
$('div').myfunction(); jquery.myfunction use create helper functions available on jquery object, such $.inarray
your last version extends $.fn object new function, , such functional equivalent of first example.
Comments
Post a Comment