Is $(function () {}) same to $(document).ready(function(){});

88 views Asked by At

As title says, I am not sure about $(function () {})

Test:

$(function () {console.log("one")});

And at the bottom of body:

 console.log("two");

the console prints two , one

Does it mean $(function () {}) is the same as $(document).ready(function(){}); ?

1

There are 1 answers

0
Brad Christie On

Yes, just $(function(){ }) is short-hand.

See the jQuery(callback) overload documentation.