title: jQuery - loop through all dynamic td elements
body: <p>I am using a PHP function to make the tables, and I want to use popovers to display an image for every table it generated. I have to loop through all the tables in order to do this, and here is my jQuery code:</p>
  
  <pre><code>&lt;script&gt;
  $("td").each(function() {
      var imagelink = "img/asdasd";
      var image = '&lt;img id="sImg" style="width: 300px; height: 100px;" src="&lt;?php echo $sImage; ?&gt;" onError="this.onerror=null;this.src=`/img/noimage.png`;"&gt;';
      $('[data-toggle="popover"]').popover({placement: 'bottom', content: image, html: true}); 
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>I used the each function but it doesn't seem to work. It only displays 1 image on 1 table.</p>
  
  <p>Thanks!</p>
  
  <p>Here's the HTML code for generating the tables:</p>
  
  <pre><code>&lt;div class="container-fluid jumbotron"&gt;
  &lt;div class="assemblies-content"&gt;
  
  &lt;?php
  
  
  
      $result = $db-&gt;prepare("SELECT * FROM `scripts` WHERE `cName` = '$camp' ORDER BY ID DESC");
      $result-&gt;execute();
      if( !$result-&gt;rowCount( ) ) echo "&lt;center&gt;&lt;h2&gt;&lt;br&gt;There aren't any scripts for this champion!&lt;/h2&gt;";
      else
      { ?&gt;
  
      &lt;table class="table"&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Script name&lt;/th&gt;
          &lt;th&gt;Author&lt;/th&gt;
          &lt;th&gt;Download Link&lt;/th&gt;          
          &lt;th&gt;GitHub Link&lt;/th&gt;
          &lt;th&gt;Thread Link&lt;/th&gt;
          &lt;th&gt;Rating&lt;/th&gt;
          &lt;th&gt;Status&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
  
  &lt;?php       
          for($i=0; $row = $result-&gt;fetch(); $i++)
          {
                  if( $row['Status'] == 'Working' ) $status = 'success';
                  if( $row['Status'] == 'Working' ) $statustext = 'Working';
                  if( $row['Status'] == 'Broken' ) $status = 'danger';
                  if( $row['Status'] == 'Broken' ) $statustext = 'Broken';
                  if( $row['Status'] == 'Unknown' ) $statustext = 'Unknown';
                  if( $row['Status'] == 'Unknown' ) $status = 'info';
                  $likeuri = $row['Likes'];
                  $dislikeuri = $row['DisLikes'];
                  if( $row['sImage'] == null) $sImage = 'img/noimage.png';
                  else $sImage = $row['sImage'];
  
  ?&gt;
  &lt;script&gt;
  $("td").each(function() {
      var imagelink = "img/asdasd";
      var image = '&lt;img id="sImg" style="width: 300px; height: 100px;" src="&lt;?php echo $sImage; ?&gt;" onError="this.onerror=null;this.src=`/img/noimage.png`;"&gt;';
      $('[data-toggle="popover"]').popover({placement: 'bottom', content: image, html: true}); 
  });
  &lt;/script&gt;
  
  &lt;?php       
              echo "&lt;tr class = '$status' data-container='body' data-toggle='popover' data-trigger='hover' data-placement='bottom' data-content=''&gt;&lt;td style='width: 250px'&gt;".$row['sName']."&lt;/td&gt;&lt;td style='width: 200px'&gt;".$row['sAuthor']."&lt;/td&gt;&lt;td&gt;&lt;a href= '".$row['dLink']."' &gt;Click&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href= '".$row['gLink']."' &gt;Click&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&lt;a href= '".$row['Thread']."' &gt;Click&lt;/a&gt;&lt;/td&gt;&lt;td style='width: 100px'&gt;&lt;span style='float:left; padding-right:10px; padding-top:2px;'&gt;".$row['Rating']."&lt;/span&gt;&lt;form action='' method='post'&gt;&lt;button style='padding: 0px 2px;' type='submit' name='Like' value='".$row['ID']."'&gt;&lt;img src='img/like.png' alt='Like' align='middle'&gt;&lt;/button&gt;
              &lt;button style='padding: 0px 2px;' type='submit' name='DisLike' value='".$row['ID']."'&gt;&lt;img src='img/dislike.png' alt='Dislike' align='middle'&gt;&lt;/button&gt;&lt;/form&gt;&lt;/td&gt;&lt;td&gt;$statustext&lt;/td&gt;";
          }
  
  ?&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
      &lt;?php }  ?&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p></p>