This article mainly introduces the differences between jQuery (function () {}) and (function () {}) (jQuery). For more information, see, I hope to help you. Jquery is an excellent Javascr into pt framework. Now we will discuss the functions executed after loading two pages in Jquery.
$ (Document). ready (function (){
// Write your code here...
}); The Code that runs when the DOM is loaded.
Can be abbreviated
JQuery (function (){
});
(Function ($) {}) (jQuery) What does it mean?
(Function (){
}) (JQuery );
It is actually executing the () (para) anonymous method, but passing the jQuery object.
Equivalent
Function aa ($ ){}
Aa (jQuery)
Is the usual method for initializing jquery objects.
In layman's terms, the code you need is executed after the page is loaded.
However, this may sometimes make the page beat. Many JQUERY plug-ins change the style only after loading is complete, and the page will feel beating or flashing. for example, ui. the tab plug-in, where there are multiple page elements, all of which are displayed to form a TAB.
(Funtion () {}) (); execute the function immediately. It is equivalent to declaring a function and calling it directly after the declaration;
If the parameters are as follows:
(Funtion (str) {alert (str)}) ("output"); equivalent to: funtion OutPutFun (str) {alert (str );}; outPutFun ("output ");
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.