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

Popular posts from this blog

java - NullPointerException for a 2d Array -

python - Assemble mpeg file unable to play in mediaplayer -

asp.net - MVC [HandleError] HandleErrorAttribute called twice when using global logging -