Adnan
Adnan

Reputation: 1409

$$ and $ in PrototypeJs

I am new to PrototypeJs. I am searching for different tutorials to increase my knowledge for this. Suddenly I observed that Magento also using Prototype with double $$ (dollar signs) instead single $ (dollar sign). So what is the different between single and double dollar sign in prototype. Assume the following example

function test(){
    div = $("div");
    alert(div.innerHTML);
}

but in magento (also found in many tutorials, peoples are using $$), like

function test(){
    div = $$("div");
    alert(div.innerHTML);
}

Any body to help me out with this.

Upvotes: 2

Views: 329

Answers (2)

Jai
Jai

Reputation: 74738

That says:

 $('div') // document.querySelector('div') <----single first element in collection
$$('div') // document.querySelectorAll('div') <----collection of all divs

$$ prototype docs.

Upvotes: 4

Gino Pane
Gino Pane

Reputation: 5011

"$" stands for select by ID.

"$$" stands for select by class and by tag.

For more info: http://www.webmonkey.com/2010/02/get_started_with_prototype/

Upvotes: 1

Related Questions