1

What's the difference between :

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

and

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

and what mean this $() ?

Hayi
  • 6,972
  • 26
  • 80
  • 139
  • 1
    Both are same, $(function()) was introduced later with upgraded version of jQuery – K D May 09 '14 at 09:27

2 Answers2

3

As stated in the docs http://api.jquery.com/ready/

$( document ).ready(function() {
  // Handler for .ready() called.
});

Which is equivalent to calling:

$(function() {
  // Handler for .ready() called.
});

$ is just a variable name / shortcut for jQuery

so you're basically calling the function jQuery() and passing some parameters to it or calling it's methods

Spokey
  • 10,974
  • 2
  • 28
  • 44
2

There is no difference between the two, the first one is the alias for the second one.

Balachandran
  • 9,567
  • 1
  • 16
  • 26