title: Walking the DOM (javascript)
body: <p>I'm attempting to walk the DOM of a page using javascript, and do a simple alert on every tag, to display the tagName attribute.  It doesn't seem to be working.</p>
  
  <p>This is the code and the HTML in a jsfiddle (and beow)
  <a href="https://jsfiddle.net/fluffymuffins/fw208ozk/" rel="nofollow">https://jsfiddle.net/fluffymuffins/fw208ozk/</a></p>
  
  <p>I don't see any alerts.  What's wrong?</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;body&gt;
  test text
  &lt;p&gt;
  some paragraph
  &lt;/p&gt;
  &lt;img src="http://example.com/image.jpg"&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>var results = [];
  
  walkDOM(document.body, function(node) {
      alert(node.tagName);
  });
  
  var walkDOM = function (node,func) {
          func(node);                     //What does this do?
          node = node.firstChild;
          while(node) {
              walkDOM(node,func);
              node = node.nextSibling;
          }
  
      };
  </code></pre>