3

What does the below line mean? It passes function($) as a parameter into jQuery?

jQuery(function ($) {
  // ...
});
user2864740
  • 60,010
  • 15
  • 145
  • 220
Axar
  • 521
  • 1
  • 3
  • 11
  • Please don't answer, there are many duplicate .. [and yes, it passes a new "anonymous" function] – user2864740 Feb 19 '15 at 21:35
  • 2
    @user2864740 damn, was too slow to find a dup... – Karl-André Gagnon Feb 19 '15 at 21:36
  • I can't find this exact scenario – Axar Feb 19 '15 at 21:36
  • 1
    @Karl-AndréGagnon Beat me though! I know there are exact duplicates ("what does this idiomatic use of $.ready mean", eg.) but kept finding higher-level questions. – user2864740 Feb 19 '15 at 21:37
  • May still be worth the permutated phrasing. – Mike Lyons Feb 19 '15 at 21:38
  • 1
    @MikeLyons Found some: http://stackoverflow.com/questions/6454631/jquery-newbie-what-does-jqueryfunction-means?rq=1 , http://stackoverflow.com/questions/27829847/jquery-function-what-does-it-mean?rq=1 , http://stackoverflow.com/questions/24226886/what-does-function-in-jquery-mean?rq=1 – user2864740 Feb 19 '15 at 21:39

1 Answers1

2

It means, "treat this $ as if I were calling jQuery() when I use $() anywhere inside this anonymous function."

Jquery documentation: http://learn.jquery.com/using-jquery-core/

Mike Lyons
  • 1,748
  • 2
  • 20
  • 33