[whatwg] nextSiblingElement ?

Maciej Stachowiak mjs at apple.com
Wed Jan 23 23:30:32 PST 2008


On Jan 23, 2008, at 10:50 PM, Garrett Smith wrote:

> nextSibling and previousSibling are useful, but not always what I  
> want.
>
> I usually want to get a siblingElement than a sibling, which might be
> a  text node.
>
> 	Dom.findNextSiblingElement = function(el) {
> 		for(var ns = el.nextSibling; ns != null; ns = ns.nextSibling)
> 			if(ns.nodeType == 1)
> 				return ns;
> 			return null;
> 	};
>
> The same is true for childNodes.
>
> It would be useful to have:
>
> nextSiblingElement,
> previousSiblingElement,
> childElements

The W3C's Web API Working Group is working on an "Element Traversal"  
spec that provides functionality like this.

Cheers,
Maciej




More information about the whatwg mailing list