tags:

views:

110

answers:

3

what is difference of $(function(){ }); and $(document).ready(function() { }) ;?

+4  A: 

Nothing whatsoever.

This function behaves just like $(document).ready(), in that it should be used to wrap other $()

You can see this in the source code:

rootjQuery = jQuery(document);

...

} else if ( jQuery.isFunction( selector ) ) {
    return rootjQuery.ready( selector );
}
SLaks
There is a difference, $(function(){}) is less readable (to my brain at least).
Rosdi
+3  A: 

$(function(){}) is a short cut for the dom ready

A function passed as an argument to the jQuery constructor is bound to the document ready event.

XGreen
A: 

Thanks Guys I was confused

Starx