Share some of the lessons learned when developing jquery plugins.
First, look at
JQuery (function () {});
All written as
JQuery (document). Ready (function () {});
The meaning is that the ready () method is executed after the DOM has been loaded.
Second, look again
(function () {}) (JQuery);
It is actually an anonymous method of executing () (para), except that the jquery object is passed.
Iii. Summary
JQuery (function () {}), which holds the code for manipulating the DOM object, and the DOM object already exists when the code executes it. cannot be used to store code that develops plug-ins, because jquery objects are not passed, and external methods (functions) cannot be called by Jquery.method.
(function () {}) (JQuery), which is used to store the code that develops the plug-in, and the DOM does not necessarily exist when executing the code, so be careful with the code that automatically executes DOM operations directly.
The difference between jquery (function () {}) and (function () {}) (jquery)