title: Using Nodelists to Change Background Color of Page
body: <p>I'm trying to create two functions that will change the background color of my HTML page when the value of an input box (color selector) is changed.</p>
  <p>Here is my JavaScript:</p>
  <pre><code>function backgroundColor() {
    let bod = document.getElementsByTagName(&quot;body&quot;)[0];
    let bgc = document.getElementById('bgColor');
  
    bgc.addEventListener(&quot;change&quot;, function(){
      color(bod, bgColor.value);
    });
  }
  
  function color(node, color){
    for (let n of node){
      n.style.backgroundColor = color;
    }
  }
  </code></pre>
  <p>and the HTML:</p>
  <p><code>&lt;p&gt;Background Color: &lt;input type=&quot;color&quot; id=&quot;bgColor&quot; value=&quot;#FFFFFF&quot;/&gt;&lt;/p&gt;</code></p>
  <p>I'm not sure how to format this, so sorry if it's unclear!</p>