title: JQuery each function to fill array with attributes from HTML images
body: <p>I'm trying to load an array filled with the src attribute from a series of img tags in my HTML document. </p>
  
  <p>HTML:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;
      JQuery Slider
  &lt;/title&gt;
  &lt;link rel="stylesheet"  type="text/css" href="css/main.css"&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" src="js/main.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;div id = "wrapper"&gt;
      &lt;h1 class="dark-header"&gt;2014 Salt Lake Comic Con FanX&lt;/h1&gt;
          &lt;div id="background-img"&gt;
              &lt;img src="img/img01.jpg"/&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;img src="img/img02.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img03.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img04.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img05.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img06.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img07.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img08.jpg"/&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;img src="img/img09.jpg"/&gt;
          &lt;/div&gt;
                  &lt;div&gt;
              &lt;img src="img/img10.jpg"/&gt;
          &lt;/div&gt;
      &lt;/div&gt;
  
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JQuery:</p>
  
  <pre><code>$(document).ready(function() {
  
  
  
      var source = new Array();
  
  
      $('img').each(function(attr) {
          source.push($('img').attr('src'))
      });
  
  
  
      console.log(source)
  
  });//end document.ready
  </code></pre>
  
  <p>The output to the console is an array of 10 elements, but only using the first img attribute. I'm not sure how to get the each function to go through all elements and push them to the array.</p>