1
I wonder why there is this instruction (jQuery)
at the end of function
.
jQuery(function($){
// alert('Oi');
$(".widgets-holder-wrap").removeClass('closed');
})(jQuery);
1
I wonder why there is this instruction (jQuery)
at the end of function
.
jQuery(function($){
// alert('Oi');
$(".widgets-holder-wrap").removeClass('closed');
})(jQuery);
2
When you write (function() { ... })()
you are making the code within the literal function (literal Function), so that the whole object is actually a function. Then you are calling the function, with the ()
at the end. This is used to control the visibility of functions and variables. jQuery plugins are usually written like this.
Being a function, you can pass whatever you want to us () at the end. For example:
(function(jQ) { ... })(jQuery)
This is the definition of a function that takes a jQ parameter (known only in the context of the function) that is then being called by passing a parameter (which in this case is external, a reference to jQuery).
Working in this way brings some advantages:
Perfect !!! :)
Browser other questions tagged jquery
You are not signed in. Login or sign up in order to post.
This may help. http://simplesideias.com.br/design-patterns-no-javascript-module
– Guilherme Lautert