11
Whenever I go to work with jQuery I just create:
$(function() {
});
Because it was the first way I learned, at first I thought it was a "int main()" pattern in C, but then I came across other forms like:
$( document ).ready(function() {
});
$(function() {
});
$j(function() {
});
function funcao(jQuery) {
}
$( document ).ready(funcao);
What is the right way to use it? Or what is the right time to use it? Why does pure Javascript not need it? What is its function?
function () {}
is Javascript, in case you want to know the difference of$()
and$.ready
, I’ll edit the title.– Guilherme Nascimento