0

Possible Duplicate:
What is the meaning of “$” sign in javascript

This may be a basic question, but I dare ask.

While I was navigating javascript codes, I found the following.

    if(selected_len == all_len) {
        $(":checkbox:checked.node_id_"+d.nodeValue).click();
    }

I tried to search what $("") means, but all I found is

"$('hello') --- This is a function declared by many JavaScript frameworks as an extension of document.getElementById."

Could you give more precise explanation, as if you talk to a child :)

Community
  • 1
  • 1
jaeyong
  • 8,951
  • 14
  • 50
  • 63
  • 3
    that's probably a jquery selector (http://api.jquery.com/category/selectors/), but it depends on whatever has been assigned to $ sign – Willem D'Haeseleer Aug 06 '12 at 12:49
  • ...this has been [asked many times before](http://stackoverflow.com/search?q=what+does+dollar+sign+%24+in+javascript+mean). Please do basic research before asking a question. –  Aug 06 '12 at 13:04

3 Answers3

5

$ is a variable name. It means whatever the function assigned to that variable is defined as. (It is not a good variable name.

The contents of it looks like a CSS selector, so odds are that it is the common, quick to type, reference to the jQuery object.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
4

In theory it doesn't mean anything more than foo() means: it's a function call, where $ is the name of the function ($ is a legal name for an identifier in Javascript).

In common practice, $ is the "entry point" for the well-known jQuery library. There are other libraries that use the name $ as an entry point, but jQuery is arguably the most widely used.

Jon
  • 428,835
  • 81
  • 738
  • 806
1

As others said, it's just a function name and if you use other libraries that are using $ sign, you can use jQuery keyword instead of $ sign.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
sedran
  • 3,498
  • 3
  • 23
  • 39