0

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

I've encountered a code in JavaScript that looks like this:

$('svg circle').tipsy({ 
    gravity: 'w', 
    html: true, 
    title: function() {
      return 'Color: '; 
    }
});

What does $('') mean here?

Community
  • 1
  • 1
user1079950
  • 151
  • 2
  • 2
  • 6

3 Answers3

5

This is from using the jQuery library, which is used to standardize JavaScript usage between browsers and make accessing elements and other common tasks much, much easier. It is not a part of JavaScript itself, except insofar as $ is an acceptable name for a function or variable.

Chris Hayes
  • 11,471
  • 4
  • 32
  • 47
4

Usually when you encounter $(), that means the developer is using a javascript library, such as jQuery.

The $ symbol is the namespace for those libraries. All the functions they define begin with $., such as $.get(). Passing the id of an html tag like this: $("#myId") will give you a jQuery object representing that node.

Indigenuity
  • 9,332
  • 6
  • 39
  • 68
2

This is the shorted initializing function for jQuery or zeptojs

$("selector").method();

It can also mean an shorten for document.getElementById if the framework is used:

$('myId'); // document.getElementById("myId");

The plugin tipsy is used witch creates tooltips on hover.

Andreas Louv
  • 46,145
  • 13
  • 104
  • 123