| Start |
|---|
| Plugins - Getting Started The jQuery API may be extended by adding to its prototype. For example, the existing API already has many functions available such as The jQuery prototype is exposed through Adding functions to this prototype will allow those functions to be available to be called from any constructed jQuery object (which is done implicitly with each call to jQuery, or each call to $ if you prefer). A constructed jQuery object will hold an internal array of elements based on the selector passed to it. For example, The Basic Plugin: jsFiddle example (opens new window) Chainability & Reusability Unlike the example above, jQuery Plugins are expected to be Chainable. Allowing one to use the same plugin on different Collections passing different customization options plays an important role in Customization / Reusability jsFiddle demo (opens new window) Freedom The above examples are in the scope of understanding basic Plugin creation. Keep in mind to not restrict a user to a limited set of customization options. Say for example you want to build a the user can now pass a desired text and have complete control over the added styles by using a custom CSS class: |
| jQuery.fn.extend() method This method extends the jQuery prototype ($.fn) object to provide new custom methods that can be chained to the jQuery() function. For example: |
Read Article
https://develop.horje.com/learn/1434/reference