YUI - getElementsBy TagName
Similar to jQuery, MooTools and other Javascript libraries, Yahoo!’s YUI DOM utility offers upgraded element searches. finding an element by class name is nice, but what if you want to find an element by tag name?
YUI does not have a function named getElementsByTagName, but the getElementsBy will do just that.
getElementsBy(method, tag, root, apply)
The method attribute is the important one here. The tag, and root are mainly there to offer optimization by reducing the possible scope of items the method is ran against.
If all you need is elements by a certain tag name, just pass in a function into the first argument that always returns true, and make sure to pass in a tag name for argument 2 that your looking for.
For example,
var forms = yDom.getElementsBy(function(el){return true;},'form'); should return an array of form elements that can be accessed further.
If you need a more specific filter (e.g. only ‘a‘ tags with class=’selected’) you could interact with the el item in the function. If you return true, the item will be added to the list. Otherwise return false and it won’t be in the array.
A good resource for more YUI Dom fun can be found at klauskomenda.com