Search code examples
prototypejs

Prototype: find all elements with a certain class?


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


Solution

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