Prototype: find all elements with a certain class?

Readonly picture Readonly · May 22, 2009 · Viewed 12.7k times · Source

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

Answer

Codebeef picture Codebeef · May 22, 2009

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")