getElementsBySelector :: Element

getElementsBySelector(element, selector...) -> [HTMLElement...]

 

Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended children of element that match any of them.

 

This method is very similar to $$() and therefore suffers from the same caveats. However, since it operates in a more restricted scope (element’s children) it is faster and therefore a much better alternative. The supported CSS syntax is identical, so please refer to the $$() docs for details.

 

Examples

 

<ul id="fruits">

  <li id="apples">

    <h3 title="yummy!">Apples</h3>

    <ul id="list-of-apples">

      <li id="golden-delicious" title="yummy!" >Golden Delicious</li>

      <li id="mutsu" title="yummy!">Mutsu</li>

      <li id="mcintosh">McIntosh</li>

      <li id="ida-red">Ida Red</li>

    </ul>

    <p id="saying">An apple a day keeps the doctor away.</p>  

  </li>

</ul>

 

$('apples').getElementsBySelector('[title="yummy!"]');

// -> [h3, li#golden-delicious, li#mutsu]

 

$('apples').getElementsBySelector( 'p#saying''li[title="yummy!"]');

// -> [h3, li#golden-delicious, li#mutsu,  p#saying]

 

$('apples').getElementsBySelector('[title="disgusting!"]');

// -> []

 

 


Prototype API 1.5.0 - prototypejs.org