-2

Hi I'm new to jQuery and I would like to know the difference between:

$(function() { });

and

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

Thanks!!

pmandell
  • 4,288
  • 17
  • 21
joseagaleanoc
  • 575
  • 2
  • 7
  • 20

2 Answers2

2

The first notation :

$(function(){ ... });

is short-hand for the second-choice :

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

They will both do the exact same thing, however the first will just require slightly less code.

Rion Williams
  • 74,820
  • 37
  • 200
  • 327
0

no difference - just different notation

Aris
  • 4,643
  • 1
  • 41
  • 38
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – eugen Jul 26 '13 at 14:07
  • 2
    question was 'what is the difference'. – Aris Jul 26 '13 at 14:08
  • @Aris I agree. Though succinct, it does answer the question. That said, a reference to the documentation is always desirable. – Wiseguy Jul 26 '13 at 15:14