title: Uncaught ReferenceError: Invalid left-hand side in assignment javascript
body: <p>I need to set all elements with a specific class to have a certain background-color.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>/*var elements = $(".km-flat");
      var elements1 = $(".km-view");
      var elements2 = $(".km-navbar");
      var elements3 = $(".km-content");
      elements.style.background-color = "red";
      elements1.style.background-color = "red";
      elements2.style.background-color = "red";
      elements3.style.background-color = "red";*/
  
      var myElements = document.querySelectorAll(".km-content");
  
      for (var i = 0; i &lt; myElements.length; i++) {
          myElements[i].style.background-color = "red";
      }
  </code></pre>
  
  <p>As you can see my first attempt was no good and is commented out. My second attempt is saying <code>Uncaught ReferenceError: Invalid left-hand side in assignment javascript</code>. </p>
  
  <p>What syntax should I be using? Thanks.</p>