title: getJSON For Loop on each div
body: <pre><code>$(document).ready(function(){
      var klient = 'tokenkeyvaluehere';
      var firstlink = 'https://graph.facebook.com/v2.8/me?fields=id,name,posts&amp;access_token='+klient;
      $.getJSON(firstlink, function(dayta){
  
          var haitchteamel = "";
          var el = $('#facebookapi'); 
              $.each(dayta.posts.data, function(key, val){
  
                  function firstpart(){return val.message;}
  
          var secondlink = 'https://graph.facebook.com/v2.8/'+val.id+'?fields=attachments&amp;access_token='+klient;      
                      $.ajax({
                          url: secondlink,
                          success: function(result){
                              var theterms = result.attachments.data[0].media.image.src;
                              for (i = 0; i &lt; document.getElementsByClassName('bisniss').length; i++){
                                  $('.picture').eq(i).html('&lt;img src="'+theterms+'"/&gt;');
  
                              }
                          }
                      });
  
                      haitchteamel += `&lt;div class="col-xs-12 col-sm-4 bisniss"&gt;
                      &lt;p&gt;`+firstpart()+`&lt;/p&gt;
                      &lt;div class="picture"&gt;&lt;/div&gt;
                      &lt;/div&gt;`;
              });
          el.html(haitchteamel);
      });
  }); 
  </code></pre>
  
  <p>I am having a bit of an issue with my for loops. I have added my full code for context, but the only part I have an issue with is on <code>$('.picture')</code>.</p>
  
  <p>For some context, I am using the Facebook API to get each post, as seen on <code>firstlink</code> and <code>firstpart()</code>. Using the <code>val.id</code> that I get from this call, I use the info to get the attachment(ie photos) accompanying each post. </p>
  
  <p>My current problem is that <code>.picture</code> retrieves only one of the pictures from my posts and spread them throughout every <code>.picture</code> div. My goal is to have only the accompanying pictures of each post. </p>
  
  <p>There is clearly something that I am not understanding about the use of For Loops. Either that, or there is a problem with my dom implementation over <code>.picture</code>. </p>