tags:

views:

107

answers:

5
 var allRapidSpells = $$('input[value^=RSW]');

Can anyone tell me what that does?

+2  A: 

Return all inputs that hava value starting with RSW

Daniel Moura
A: 

It looks like it uses some CSS selectors using some javascript library, the CSS selectors return all input tags where the value begins RSW.

scragar
A: 

calls a method on the windows object called $$ and passes a string argument to it, which appears to be an xpath expression.

which returns input tags that contain an attribute called value starting with RSW.

DevelopingChris
+1  A: 

It calls the function named '$$' with the parameter 'input[value...' and assigns the returnvalue of that function to the var allRapidSpells.

Javascript doesn't consider the '$' to be a reserved character, which jQuery makes excellent use of.

ylebre
+5  A: 

I would venture to guess that you're using MooTools, a JavaScript framework. The $$() function is used to select an element (or multiple elements) in the DOM.

More specifically, the $$('input[value^=RSW]'); syntax is selecting all input elements whose value attribute starts with RSW.

Other attribute selectors include:

  • = : is equal to
  • *= : contains
  • ^= : starts-with
  • $= : ends-with
  • != : is not equal to
  • ~= : contained in a space separated list
  • |= : contained in a '-' separated list

Edit: It looks as though Prototype, another JavaScript framework, uses the same syntax.

John Rasch