I would like to share some of my experiences when developing jQuery plug-ins.
I. First read
JQuery (function (){
});
Write All
JQuery (document). ready (function (){
});
It means that the ready () method is executed after the DOM is loaded.
2. Check again
(Function (){
}) (JQuery); www.2cto.com
It is actually executing the () (para) anonymous method, but passing the jQuery object.
Iii. Summary
JQuery (function () {}); used to store the code that operates the DOM object. When the code is executed, the DOM object already exists. It cannot be used to store the code of the Development plug-in. Because the jQuery object is not passed, the method (function) cannot be called externally through jQuery. method ).
(Function () {}) (jQuery); used to store the code of the Development plug-in. DOM does not necessarily exist when executing the code. Therefore, use the code that directly performs DOM operations with caution.
Author: xiahuawuyu