Prototype: find all elements with a certain class?

12,696

Solution 1

You can use the $$ function to get elements by class:

$$(".myclass")

Will give you an array of elements you can iterate over. This function allows you to use any css selector to get the elements, too:

$$("li.myclass")
$$("p#test")

Solution 2

http://prototypejs.org/doc/latest/dom/dollar-dollar

$$ lets you pass in any css selector.

$$('.class')
Share:
12,696
readonly
Author by

readonly

Readonly

Updated on June 14, 2022

Comments

  • readonly
    readonly about 2 years

    Using the Prototype js framework, how do you find all elements with a certain class?

  • JMTyler
    JMTyler over 11 years
    For any who come across this in the future: it looks like this function is available in PrototypeJS 1.5+. If I'm wrong about this, someone please correct me.