0

Possible Duplicate:
Is there a difference between $().ready() and $(document).ready()

I am trying to setup jquery ui tabs for a page and I used

$(document).ready(function(){
    $('#tabs').tabs();
});

which did not work. So I checked their example and saw a different syntax which now worked

$(function(){
    $('#tabs').tabs();
});

What's the difference between the two syntaxes?

Community
  • 1
  • 1
codingbiz
  • 26,179
  • 8
  • 59
  • 96

1 Answers1

2

They are equivelent. http://api.jquery.com/ready/

The .ready() method is typically used with an anonymous function:

$(document).ready(function() {
  // Handler for .ready() called. 
});

Which is equivalent to calling:

$(function() {  
  // Handler for .ready() called. 
});

If .ready() is called after the DOM has been initialized, the new handler passed in will be executed immediately.

Matthew Blancarte
  • 8,251
  • 2
  • 25
  • 34