How to write my first jQuery plugin?

Now I am writing my first jQuery plugin, and I found this blog post about "Created the first jQuery plugin" , but in the first step they give two ways to write the plugin: First:


$.fn.yourPlugin = function(options) {

   return this.each(function() {

   });
};


And the second one:


(function($){
 $.fn.yourPlugin = function() {

    return this.each(function() {

    });
 };
})(jQuery);


Because they say that there may be problems with $conflicts similar to other libraries ....

So, I would like to know what is the best practice here.

0
source share
4 answers

. , , $ jQuery.

+7

. $ , , $.

+1

jQuery - JS- ( JS-). - , .

, : jquery plugin hello

, , , .

+1

All Articles