Search code examples
javascriptprototypejs

What does $$ mean in Javascript?


I am looking at some javascript code and it has this in a function:

$$('.CssClass').each(function(x) { .... } )

I get that the intent is to apply the anonymous function to each element with a class of CssClass, but I can't work what the $$ refers to ... and can't google for $$!

Update: thanks for the hints. The javascript comes from the iPhone look-alike library: jPint which includes the prototypejs library, and does define $$ as:

function $$() {
  return Selector.findChildElements(document, $A(arguments));
}

Solution

  • Probably this prototype function:

    $$(cssRule...) -> [HTMLElement...]
    

    Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended DOM elements that match any of them.

    http://www.prototypejs.org/api/utility#method-$$