Are these both the same thing, i.e. ways of saying document ready:
$(function() {
//
});
and
$(function($) {
//
})(jQ
This one is incorrect:
$(function($) {
//
})(jQuery);
You're passing a function to $(...)
, then calling the result. However, the result of $(...)
is a jQuery object, which is not a function. You might see it better this way:
$(
function($) {
//
}
)
(jQuery);
Generally, there are three versions of document.ready
, which are all equal to each other:
$(function() {...});
$(document).ready(function() {...});
$().ready(function() {...});