what is difference of $(function(){ }); and $(document).ready(function() { }) ;?
views:
110answers:
3
+4
A:
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
2010-04-18 15:39:47
There is a difference, $(function(){}) is less readable (to my brain at least).
Rosdi
2010-04-19 03:27:43
+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
2010-04-18 15:40:22