GetNextStructuredSibling( objNode )
Downloadable Files
getnextstructuredsibling_function1.htm ( 3,759 Bytes )
GetNextStructuredSibling() method traverses the sibling chain in the document object model (DOM) searching for the closest next sibling that is a structured node (ie. not a text node; node of type 3). This is an important function for use in cross-browser scripting where different browsers may or may not acknowledge the existence of text nodes in between structured elements (that are not necessarily expected, such as text nodes between a close and open TR's in a table).
- function GetNextStructuredSibling( objNode ){
-
- // Travel down the sibling chain looking for a non-text node.
- for (
- objNode = objNode.nextSibling ;
- (
- objNode &&
- objNode.nodeType == 3
- ) ;
- objNode = objNode.nextSibling
- ){
- // Nothing has to happen here. The FOR loop itself is taking care
- // of the node traversing. We don't have to really worry about any
- // error checking as we can't really make it outside of HTML DOM
- // elements without hitting a structured node, or coming up with NULL.
- }
-
- // Return the sibling node.
- return( objNode );
-
- }
Added May 3, 2006 / Updated May 3, 2006



