Reputation: 270
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';
}
});
}
Upvotes: 0
Views: 277
Reputation: 19915
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.
Upvotes: 0
Reputation: 2700
$ 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
Upvotes: 2
Reputation: 6770
$$ 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();
Upvotes: 0
Reputation: 2679
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 :
$$$$($$$[$]);
Upvotes: 2