title: Change color on all element using a css class
body: <p>I try to change color in all elements in class, but I have an error:</p>
  
  <blockquote>
    <p>Cannot convert undefined or null to object</p>
  </blockquote>
  
  <p>I have code:</p>
  
  <pre><code>&lt;div class="kolorek" onclick="changeColor('34495e');" style="background-color:#34495e;"&gt;&lt;/div&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>function changeColor(color) {
      var block = document.getElementsByClassName('kafelek');
      with (block.style) {
          backgroundColor = "#" + color;
      }
  };
  </code></pre>