Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does $('') mean in JavaScript? [duplicate]

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?

like image 828
user1079950 Avatar asked Sep 19 '26 18:09

user1079950


2 Answers

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.

like image 106
Indigenuity Avatar answered Sep 21 '26 08:09

Indigenuity


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.

like image 32
Chris Hayes Avatar answered Sep 21 '26 06:09

Chris Hayes