-1

Possible Duplicate:
Differences between document.ready and $function

I think it is a stupid question, but, Can someone show me the differences between these two call types?

$(function(){
//do somenthing
});

and

$(document).ready(function(){
//do somenthing
});
Community
  • 1
  • 1
itsme
  • 48,972
  • 96
  • 224
  • 345
  • 1
    Do a search and you'll find hundres of duplicate questions, and the answer is always the same, they are equal. – adeneo Dec 17 '12 at 19:18

2 Answers2

1

They are the exact same thing. The top one is just a shortcut

From jquery doc:

All three of the following syntaxes are equivalent:

$(document).ready(handler)
$().ready(handler) (this is not recommended)
$(handler)

.ready() jQuery API

Ibu
  • 42,752
  • 13
  • 76
  • 103
1

All three of the following syntaxes are equivalent:

$(document).ready(handler)

$().ready(handler) (this is not recommended)

$(handler)

See Link

Community
  • 1
  • 1
Anujith
  • 9,370
  • 6
  • 33
  • 48