What's the difference between $(document).ready(…) and $(function() {}) in jQuery? -


what's difference between:

$(document).ready(function() {// something}); 

and

$(function() {//do something}); 

in jquery?

$(document).ready(handler) $().ready(handler) (this not recommended) $(handler) 

are equivalent.

actually, can call .ready(handler) on any jquery object, no matter contains, , same thing:

ready: function( fn ) {     // attach listeners     jquery.bindready();      // add callback     readylist.add( fn );      return this; }, 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -