Skip to Content
JavaScript: The Definitive Guide, Fourth Edition
book

JavaScript: The Definitive Guide, Fourth Edition

by David Flanagan
November 2001
Intermediate to advanced
936 pages
68h 43m
English
O'Reilly Media, Inc.
Content preview from JavaScript: The Definitive Guide, Fourth Edition

Name

NodeIterator.nextNode( ) — iterate to the next node

Availability

DOM Level 2 Traversal

Synopsis

Node nextNode(  )    
    throws DOMException;

Returns

The next node in the sequence of nodes represented by this NodeIterator, or null if the last node has already been returned.

Throws

If this method is called after a call to detach( ), it throws a DOMException with a code of INVALID_STATE_ERR.

Description

This method iterates forward through the sequence of nodes represented by this NodeIterator. If this is the first time it is called for a NodeIterator, it returns the first node in the sequence. Otherwise, it returns the node that follows the one that was previously returned.

Example

// Create a NodeIterator to represent all elements in the document body
var ni = document.createNodeIterator(document.body, NodeFilter.SHOW_ELEMENT,
                                     null, false);
// Loop forward through all nodes in the iterator
for(var e = ni.nextNode(  ); e != null; e = ni.nextNode(  )) {
    // Do something with element e
}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

JavaScript: A Beginner's Guide, Fourth Edition, 4th Edition

John Pollock
JavaScript Cookbook, 3rd Edition

JavaScript Cookbook, 3rd Edition

Adam D. Scott, Matthew MacDonald, Shelley Powers

Publisher Resources

ISBN: 0596000480Supplemental ContentCatalog PageErrata