[javascript] What does the "$" sign mean in jQuery or JavaScript?

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

Now this must seem to be an easy and stupid question to ask but I must know why we use the dollar ($) symbol in jQuery and JavaScript. I always put a dollar in my scripts but I actuary don't know why.

For an example:

$('#Text').click(function () {
  $('#Text').css('color', 'red')
});

This just changes the text colour when you click it, but it demonstrates my point.

This question is related to javascript jquery

The answer is


The $ is just a function. It is actually an alias for the function called jQuery, so your code can be written like this with the exact same results:

jQuery('#Text').click(function () {
  jQuery('#Text').css('color', 'red');
});

In jQuery, the $ sign is just an alias to jQuery(), then an alias to a function.

This page reports:

Basic syntax is: $(selector).action()

  • A dollar sign to define jQuery
  • A (selector) to "query (or find)" HTML elements
  • A jQuery action() to be performed on the element(s)

Additional to the jQuery thing treated in the other answers there is another meaning in JavaScript - as prefix for the RegExp properties representing matches, for example:

"test".match( /t(e)st/ );
alert( RegExp.$1 );

will alert "e"

But also here it's not "magic" but simply part of the properties name


The $ symbol simply invokes the jQuery library's selector functionality. So $("#Text") returns the jQuery object for the Text div which can then be modified.


The jQuery syntax is tailor made for selecting HTML elements and perform some action on the element(s).

Basic syntax is: $(selector).action()

A dollar sign to define jQuery A (selector) to "query (or find)" HTML elements A jQuery action() to be performed on the element(s)

More on this