0

I used $ instead of document.getElementById() in javascript and i don't know what is the use of $$. Can any one please tell me what is the use of $$?

Here is the code:

var link_object = $$('a[class="menu_item"]');
if (window.location.href.search('inident.do') >= 0) {
    link_object.each(function (elem) {
        if (elem.innerHTML == 'Create an Incident') {
            elem.style.fontWeight = 'bold';
            elem.style.color = 'black';
        }
    });
}
Praveen
  • 55,303
  • 33
  • 133
  • 164

4 Answers4

2

The single $ is usually a short name for jQuery object. The double $$ could be anything.

In Angular, seems to designate a private identifier.

You can do something like this when you hate your colleagues :

$$$$($$$[$]);
FLX
  • 2,626
  • 4
  • 26
  • 57
2

$ is the selector in jquery. $$ doesn't have any specific meaning in jquery so you can use it in your own way. like this

     function $$(){
        alert('hello');
      }

    $$();

There may be other libraries like jquery which use $ or may be use $$. since $ is valid symbol in javascript for variable and function names it is the best way to simplify the dom selection instead of using long document.getElementById() like functions.

contribution of Mr. Robg

In jQuery, $ is a function that takes different types arguments. It will accept functions, arrays, objects (native and host), strings or nothing at all. If it gets a string, it will work with a selector or HTML

Tintu C Raju
  • 2,700
  • 2
  • 21
  • 25
  • 1
    In jQuery, [*$*](http://api.jquery.com/jQuery/) is a function that takes different types of arguments. It will accept functions, arrays, objects (native and host), strings or nothing at all. If it gets a string, it will work with a selector or HTML. – RobG Feb 10 '15 at 12:02
  • @RobG Thank you i've include this :-) – Tintu C Raju Feb 10 '15 at 12:11
0

$$ doesn't have any particular meaning for jQuery. But if you are using some library who can conflict with jQuery, you can change the name of $ function to anything you want by using jQuery noConflict function;

You should look for something like this early in your code

var $$ = jQuery.noConflict();
nanndoj
  • 6,580
  • 7
  • 30
  • 42
0

Are you sure this is jQuery ? It looks like mootools.

In mootools, $$() is the element selector function. It works similar to $() in jQuery.

$('id')

returns the element with id 'id'.

$$('selector') 

returns a collection of the elements corresponding to the selector passed.

Lorenz Meyer
  • 19,166
  • 22
  • 75
  • 121