Re: [Element Traversal LC] access to element by index

Henri Sivonen wrote:

> How often do people pick a single child by index (with a number know a 
> priori) instead of iterating over children and testing each one for an 
> interesting trait?

Let me turn the problem differently : NodeList and NamedNodeMap are the
normal answers when we query a list of nodes, for instance through
Document.getElementsByTagName() or Element.childNodes, why should this
behave differently and why should the DOM be inconsistent here ?
I must add that XPath also allows to select the nth child of a given
element, that Selectors can do the same through
|#myParent > :nth-child(n)|.

Apparently querying the nth element child of an element is NOT that
uncommon:

http://www.mail-archive.com/discuss@jquery.com/msg20124.html
http://groups.google.com/group/jquery-en/browse_thread/thread/f49c09bb901f7aa6
http://tinyurl.com/2wsxlc
http://www.xml.com/pub/a/2007/01/24/whats-new-in-prototype-15.html?page=4
and the list is much longer.


</Daniel>

Received on Tuesday, 1 April 2008 15:42:35 UTC