title: querySelectorAll not working for specified elements
body: <p>I'm trying to achieve to select all specified elements that i want using looped <code>querySelectorAll</code> but I'm still failing. Only the first element is always selected. Here is my code:</p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;div id="text"&gt;Text 1&lt;/div&gt;
  &lt;div id="text"&gt;Text 2&lt;/div&gt;
  &lt;div id="text"&gt;Text 3&lt;/div&gt;
  </code></pre>
  
  <p><br>
  JS:</p>
  
  <pre><code>function query(selector) {
      var elem = document.querySelectorAll(selector);
  
      if(elem.length) {
          for(var i = 0; i &lt; elem.length; i++) {
              return elem[i];
          }
      }
  }
  
  query("#text").style.background = "red";
  </code></pre>
  
  <p><br>
  What have I done wrong?</p>