Tuesday, 1 April 2014

JQuery $ vs $.fn?

$.fn points to the jQuery.prototype. Any methods or properties we add to it become available to all instance of the jQuery wrapped objects.



$.fn we will be using to create plugins and can be called using $(<someselector>).pluginname();

$.something adds a property or function to the jQuery object itself.

Use the first form $.fn.something when we're dealing with DOM elements on the page, and our plugin does something to the elements.

Use $.something When the plugin has nothing to do with the DOM elements.

No comments:

Post a Comment

Thank you so much for providing your valuable feedback. I will will look into them and update my skills & technologies accordingly.