Is it the same as defining doSomething()
inside of jQuery
and removing the $
?
If you mean, is it the same as:
(function ($){
$(function () {
function doSomething($, $variable){
}
doSomething($('.div'));
});
}(jQuery));
...then no, because in the version in your question, doSomething
is apparently global, whereas if you define it within another function, it isn't.
The structure at the end of your question is meant to protect against noConflict
mode where $
does not equal jQuery
, by creating a function and calling it, passing in jQuery
and accepting it as an argument named $
. It may be that the author was unaware of the fact that jQuery passes a reference to itself into the ready callback, so that code could more simply be:
function doSomething($, $variable){
...
}
jQuery(function($) {
doSomething ($, $('.div'));
});