Firefox only NodeIterator Example : nextNode : DOM Node JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » DOM Node » nextNode »

 

Firefox only NodeIterator Example

















<html>
<head>
<title>NodeIterator Example</title>
<script type="text/javascript">

   var iterator = null;

   function makeList() {
       var oDiv = document.getElementById("div1");
       iterator = document.createTreeWalker(oDiv, NodeFilter.SHOW_ELEMENT, null, false);

       var oOutput = document.getElementById("text1");
       var oNode = iterator.nextNode();
       while (oNode) {
           oOutput.value += oNode.tagName + "n";
           oNode = iterator.nextNode();
       }

   }

</script>
</head>
<body>
<P><strong>A:</strong> B <code>C</code> D <code>E</code> F</p>
<div id="div1">
    <P>Hello <b>World!</b></p>
    <ul>
        <li>List item 1</li>
        <li>List item 2</li>
        <li>List item 3</li>
    </ul>
</div>
<textarea rows="10" cols="40" id="text1"></textarea><br />
<input type="button" value="Make List" onclick="makeList()" />
</body>
</html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo DOM Node
» nextNode