getElementsByClassName(element, className) -> [HTMLElement...]

Fetches all of element’s descendants which have a CSS class of className and returns them as an array of extended elements.

As of Prototype 1.6, document.getElementsByClassName has been deprecated since native implementations return a NodeList rather than an Array. Please use $$ or Element#select instead.

The returned array reflects the document order (e.g. an index of 0 refers to the topmost descendant of element with class className).


<ul id="fruits">
  <li id="apples">apples
      <li id="golden-delicious">Golden Delicious</li>
      <li id="mutsu" class="yummy">Mutsu</li>
      <li id="mcintosh" class="yummy">McIntosh</li>
      <li id="ida-red">Ida Red</li>
  <li id="exotic" class="yummy">exotic fruits
      <li id="kiwi">kiwi</li>
      <li id="granadilla">granadilla</li>

// -> [li#mutsu, li#mcintosh, li#exotic]

// -> []