Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In some core Magento modules I see the $$ signs used constantly when selecting an element. For example, in just 10 lines of code I have the following different selectors:

  1. $('selection-apparently-a-custom-element')

  2. $$('#some-element-id')

  3. jQuery('#another-element-id')

What is the point of this?

share|improve this question
up vote 12 down vote accepted

There is still some prototype.js left over from Magento 1, now mixed with jQuery (in noConflict mode)

That means:

  • $ is the prototype selector that returns one element by its id
  • $$ is the prototype selector that returns an array of elements by CSS selector
  • jQuery is what would be $ in a pure jQuery environment and returns a jQuery wrapper for an element by CSS selector
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.