title: Change style.width of a div by class name
body: <p>I've been trying to change the width of a div with a set.interval animation. It works perfectly fine with getELementByID, but it won't work with getElementsByClassName.</p>
  
  <p>The code is the following:</p>
  
  <pre><code>var loadingBar = 200;
  
  function animationBarOne(){
      document.getElementsByClassName("loading-bar").style.width=(loadingBar+"px");
      loadingBar++;
      if(loadingBar === 900){
           clearInterval(intervalId);
      }
  }
  var intervalId = setInterval(animationBarOne,1);
  </code></pre>
  
  <p>I'm getting "can't set property width of undefined". As I said it works perfectly with ID, but giving I have like 10 bars to animate I rather use class name so its cleaner. </p>
  
  <p>Thanks in advance. </p>