MemoryLeak
MemoryLeak

Reputation: 7318

$$ in jQuery, what's this used for?

if someone just write:

    $("#downloadTabs>div").each(function(el) {
        el.setStyle("display", "none");
        el.removeClass('active');
    });

I would know what is this used for. But the actually code I read is

    $$("#downloadTabs>div").each(function(el) {
        el.setStyle("display", "none");
        el.removeClass('active');
    });

There is one more $, and what's this used for ?

Upvotes: 1

Views: 324

Answers (3)

James Wheare
James Wheare

Reputation: 4800

The second example is not jQuery, it's MooTools. The $$ can take a CSS selector to return a set of elements just like the $ function in jQuery: http://mootools.net/docs/core/Element/Element#dollars

prototype.js also has a very similar $$ function that's a shortcut to getElementsBySelector: http://www.prototypejs.org/api/utility/dollar-dollar

Upvotes: 11

Jan Jongboom
Jan Jongboom

Reputation: 27323

It's probably prototype http://www.prototypejs.org/api/utility/dollar-dollar, as mentioned by James.

Yet jquery could have $$, as stated in this article:

http://onehackoranother.com/projects/jquery/jquery-grab-bag/dom-builder.html

Upvotes: 2

nickf
nickf

Reputation: 545985

It might well be that to avoid conflicts with some other library, someone working on your codebase has added a line like this:

var $$ = $.noConflict();

$$ is not mentioned in the jQuery source code as far as I can see...

Upvotes: 2

Related Questions