title: Target all links within div — Javascript
body: <p>I'm trying to target links within a certain div. I understand how to target all the links, like so:</p>
  
  <pre><code>var colors = [ 'BlueViolet', 'CadetBlue', 'Coral', 'Crimson', 'DarkGoldenRod', 'DarkOliveGreen'],
      a = document.getElementsByTagName('a');
  
  for(var i = 0; i &lt; a.length; i++) {
      var elem = a[i],
          color = colors[0];
      elem.style.color = color;
      colors.push(color);
      colors.shift();
  }
  </code></pre>
  
  <p>Obviously, it's targeting all links: <a href="http://lexicantest.tumblr.com/" rel="noreferrer">http://lexicantest.tumblr.com/</a></p>
  
  <p>Is there a way for me to target all the links within a certain id/class?</p>