getElementsByTagNames() returns elements with several tag names in the order they appear in the document.Skip to comment form
One of my fondest W3C DOM wishes is a
getElementsByTagNames() method (note the plural “names”) that returns elements with several tag names in the order they appear in the document. This is extremely useful in for instance my ToC script which needs all h3s and h4s in the order they appear in the source code.
When I discovered the
compareDocumentPosition() method in Level 3 Core, I could finally write a custom script that works in most browsers.
Therefore I now proudly present my new getElementsByTagNames() script. It requires either
compareDocumentPosition to work fully, and since Safari 1.3.2 supports neither the script doesn’t sort the elements in this browser.
Post a Reply
Comments are closed.