8

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?

14

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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