W3C home > Mailing lists > Public > whatwg@whatwg.org > January 2008

[whatwg] nextSiblingElement ?

From: Cameron McCormack <cam@mcc.id.au>
Date: Thu, 24 Jan 2008 17:54:29 +1100
Message-ID: <20080124065429.GA7983@arc.mcc.id.au>
Hi Garrett.

Garrett Smith:
> 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;
> 	};

There is http://www.w3.org/TR/ElementTraversal/, which specifies just
this.

-- 
Cameron McCormack, http://mcc.id.au/
	xmpp:heycam at jabber.org  ?  ICQ 26955922  ?  MSN cam at mcc.id.au
Received on Wednesday, 23 January 2008 22:54:29 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:00 UTC