Differences between jQuery (function () {}) and (function () {}) (jQuery)
Source: Internet
Author: User
I would like to share some of my experiences when developing jQuery plug-ins. I. first look at jQuery (function () {}); write all as jQuery (document ). ready (function () {}); indicates that the ready () method is executed after the DOM is loaded. 2. Let's take a look at (function () {}) (jQuery); www.2cto.com... to share some of the experiences we have learned 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
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service