I tried googleing, but Google doesn't seem to care about parentheses...
(function($) { // do something })(jQuery); this means, that the interpreter will invoke the function immediately, and will pass jQuery as a parameter, which will be used inside the function as $ .
var flagu6=0; if( flagu1==0 && flagu2==0 && flagu3==0 && flagu4==0 && flagu6==0 ) return true; else return false; } function clearBox(type) { // Your implementation here } // Event handler $submitButton. on('click', handleSubmit); }); Now, clicking the button will go to handleSubmit function, which employs your code.
If you see this:
(function($) {
// ...code using $...
})(jQuery);
It's doing two things:
$
as its reference to jQuery.jQuery
.You could do it like this:
function foo($) {
// ...code using $...
}
foo(jQuery);
...but that creates an unnecessary symbol.
All of this is because jQuery has the symbol jQuery
and the symbol $
, but it's not uncommon for people to use jQuery.noConflict()
to tell jQuery to return $
back to whatever it was when jQuery loaded, because a couple of other popular libraries (Prototype and MooTools, to name two) use $
and this lets someone use those libraries and jQuery together. But you can still use $
within your function, because the argument shadows whatever that symbol means outside the function.
It basically automatically invokes the anonymous/lambda function defined and supplies the jQuery
reference to it.
Pretty much the same as functionCall(jQuery)
except you define it and invoke it in the same line/expression.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With