javascript - jQuery plugin template -
I'm getting this template to build a jQuery plugin
but I do not understand the code, Why declare the plugin as a method of jQuery object, and then we declare the plugin as a method of object $ .fn, why did we do this?
Adding the plugin to $
enables you to write:
var $ el = $ ("myselector"); $ .myplugin ($ el, {something: "options", second: "one"});
Writing the plugin in $ .fn
enables you to write:
$ (".myselector"). Myplugin ({some: "options", second: "one"});
Comments
Post a Comment