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,566
  • 11
  • 47
  • 57
  • 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
  • 857,932
  • 118
  • 1,152
  • 1,264
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
  • 413,451
  • 75
  • 717
  • 787
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
  • 31,815
  • 47
  • 169
  • 296
sedran
  • 3,358
  • 3
  • 21
  • 39