The NodeIterator.nextNode() method returns the next node in the set represented by the NodeIterator and advances the position of the iterator within the set. The first call to nextNode() returns the first node in the set.
This method returns null when there are no nodes left in the set.
Method of dom/NodeIteratordom/NodeIterator
Syntaxvar object = object.nextNode(/* see parameter list */);Parameters oNode
Object containing the next node in the list.
Returns an object of type DOM NodeDOM Node
Type: HRESULT
This method can return one of these values.
Return code Description S_OK The operation completed successfully. InvalidStateError _ERR NodeIterator raises this exception if detach has been invoked on the object.Object containing the next node in the list.
Examples<!DOCTYPE html> <html> <head> <title>NextNode example</title> <script type="text/javascript"> function LoseMondays(){ var ni = document.createNodeIterator(document.body, NodeFilter.SHOW_TEXT, null, false); var txt = ni.nextNode(); //go to first node of our NodeIterator while (txt) //while text { if (txt.wholeText.match('Monday') || txt.parentNode.getAttribute('id') == 'Monday') { txt.parentNode.removeChild(txt); //remove monday's activity } txt=ni.nextNode(); //go to next node } } function refresh() { window.location.reload( false ); //reload our page } </script> </head> <body> <p><strong>Harry's weekly diary</strong></p> <p>Monday Joe bought a turkey.</p> <p>Tuesday Bill bought a pound of ham.</p> <div>Chuck called in sick Monday.</div> <p id="Monday">CALL supplier today</p> <p>Wednesday's delivery was delayed.</p> <input type="button" name="reset" value="refresh" onclick="refresh()"/> <input type="button" name="cutmonday" value="Lose Mondays" onclick="LoseMondays()"/> </body> </html>Notes Remarks
This example shows how to create a NodeIterator and move forward through the list of nodes.
Syntaxnode = nodeIterator.nextNode();
Standards information Related specificationsMozilla Developer Network : [NodeIterator.nextNode Article]
Microsoft Developer Network: [nextNode Method Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4