1

Possible Duplicate:
What is the difference between these jQuery ready functions?

$(function(){
    // ... do stuff
});

VS

$(document).ready(function() {
    // ... do stuff
});

I saw the first one in some old code and I assume the two are similar? Is there a benefit to one over the other?

Community
  • 1
  • 1
Jacksonkr
  • 30,630
  • 38
  • 174
  • 276

3 Answers3

2

they are the same exact thing. i started using the 1st method now as it's more shorthand

Joel Grannas
  • 1,976
  • 2
  • 23
  • 44
1

They are the same, except the first version is just shorthand.

Oliver Spryn
  • 16,146
  • 33
  • 97
  • 186
1

According to the jQuery Documentation those are equivalent

MrOBrian
  • 2,159
  • 15
  • 13