Is there a way to use getElementsByName without starting from the DOM root.
For example I have a div element, and want to start searching from that element.
If not, then do I have to write my own function that recursively iterates through the child nodes, or is there a different way to do it.
getElementsByNameandgetElementByIdare both members of thedocumentobject, and aren’t part of theHTMLElementprototype. In modern browsers (IE8, Firefox, Chrome, Opera), you can useelement.querySelectorAll("*[name='myName']").Other than that your alternative is to use a library like Sizzle or a framework such as jQuery (which uses Sizzle) to handle selectors.