In the process of viewing a lot of jquery, you often encounter two parentheses.
For example:
(function () { alert ("Test 1");}) (); (function () { alert ("Test 3"); ());
In fact, this code defines an anonymous function and makes a call,
The equivalent of the following lines of code:
(function ListCommon2 () { alert ("Test 1");}) (); (function ListCommon3 () { alert ("Test 3"); ());
Further rewriting for our normal use is to define the function first, in the call to:
function ListCommon2 () { alert ("Test 1");}; ListCommon2 (); function ListCommon3 () { alert ("Test 3");};
This is why we use a lot of jquery plugin libraries, although we did not call, just add in, but after the page has finished loading, still do a lot of operations, such as jquery Eiasyui has obviously modified the DOM, processing a lot of custom property tags.
How do I pass arguments to such functions? As with normal functions, for example:
(function (text) { alert (text);}) ("Test 1"); (function (text) { alert (text);} ("Test 3"));