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
  • 31,583
  • 39
  • 180
  • 284

3 Answers3

2

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

Joel Grannas
  • 2,016
  • 2
  • 24
  • 46
1

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

Oliver Spryn
  • 16,871
  • 33
  • 101
  • 195
1

According to the jQuery Documentation those are equivalent

MrOBrian
  • 2,189
  • 16
  • 13