What does the "$" sign mean in jQuery or JavaScript?
In JavaScript it has no special significance (no more than a
or Q
anyway). It is just an uninformative variable name.
In jQuery the variable is assigned a copy of the jQuery
function. This function is heavily overloaded and means half a dozen different things depending on what arguments it is passed. In this particular example you are passing it a string that contains a selector, so the function means "Create a jQuery object containing the element with the id Text".
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');
});