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?

Fabian Schmengler
66.2k25 gold badges191 silver badges422 bronze badges
asked Mar 22, 2016 at 14:04

1 Answer 1

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
answered Mar 22, 2016 at 14:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.