What does $$ mean in javascript?

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

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

I understand that the goal is to apply an anonymous function to each element with the CssClass class, but I cannot work, which means $$ ... and cannot google for $$!

Update : thanks for the tips. Javascript comes from a library of similar iPhone: jPint , which includes prototypejs and defines $$ as:

 function $$() { return Selector.findChildElements(document, $A(arguments)); } 
+3
source share
6 answers

Perhaps this prototype function :

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

It takes an arbitrary number of CSS selectors (strings) and returns an array of documents with extended DOM elements that match any of them.

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

+14
source

$ is a regular character symbol, so "$", "$$", "$$$" are ordinary variables.

the value of $ depends on the libraries used; in jQuery, the $ function creates a jquery object from a css selector, for example. $ ("DIV") is the collection of all DIVs in the current document.

+8
source

Do you happen to look at a library like mootools? It is used as a short hand for certain types of objects, referring to the DOM. For example, they use, for example, $ ('myElement') to access page elements.

+4
source

$ is a valid function name in javascript. So, something defines a function $$ , which takes a string that looks for some class called .CssClass and returns the object that you call each on.

I know jQuery defines a function called $ at least, which does similar things.

+1
source

Is it likely that you are looking at a MooTools script? http://www.consideropen.com/blog/2008/08/30-days-of-mootools-12-tutorials-day-2-selectors/ (now belongs to the grabber domain)

"$$ allows you to quickly select multiple items and put them in an array (a type of list that allows you to manipulate, retrieve and reorder the list in all ways). You can select items by name (for example, div, a, img) or identifier, and you can even mix and match. "

+1
source

Most likely, the name of the shorthand function that handles DOM access to the specified arguments, be it a tag name or an object identifier.

As stated above, you are probably in MooTools or jQuery.

0
source

Source: https://habr.com/ru/post/1401806/


All Articles