title: Why is jQuery not returning nearest table row values?
body: <p>I've been trying to get the data from a table row via jQuery but it is returning nothing. I've looked around for multiple tutorials but haven't found anything that can help me.</p>
  
  <p>Here is my code:</p>
  
  <p>jquery:</p>
  
  <pre><code>function markAsRead(checkbox) {
      if (checkbox.checked) {
          var current_row = $('#msg-table').closest("tr");
  
          var column1 = current_row.find("td:eq(0)").text();
          var column2 = current_row.find("td:eq(1)").text();
          var column3 = current_row.find("td:eq(2)").text();
          var column4 = current_row.find("td:eq(3)").text();
  
          var data = column1 + " " + column2 + " " + column3 + " " + column4;
  
          console.log(data);
      } else {
          return;
      } 
  }
  </code></pre>
  
  <p>php and html:</p>
  
  <pre><code>&lt;table class="w3-table-all" id="msg-table"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt;From&lt;/th&gt;
              &lt;th&gt;Subject&lt;/th&gt;
              &lt;th&gt;Message&lt;/th&gt;
              &lt;th&gt;Date Sent&lt;/th&gt;
              &lt;th&gt;&lt;/th&gt;
          &lt;/tr&gt;
          &lt;/thead&gt;
  
  
          &lt;?php 
              foreach ($this-&gt;paginator as $value):
                  if ($value-&gt;active == 1):
          ?&gt;
              &lt;tr class="w3-hover-text-red w3-text-black"&gt;
                  &lt;td&gt;
                      &lt;b&gt;&lt;?php echo $value-&gt;from; ?&gt;&lt;/b&gt;
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      &lt;b&gt;&lt;?php echo $value-&gt;subject; ?&gt;&lt;/b&gt;
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      &lt;b&gt;&lt;?php echo $value-&gt;message; ?&gt;&lt;/b&gt;
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      &lt;b&gt;&lt;?php echo $value-&gt;date_sent; ?&gt;&lt;/b&gt;
                  &lt;/td&gt;
  
                  &lt;td&gt;
                      &lt;input type="checkbox" class="w3-check" onchange='markAsRead(this);' id="&lt;?php echo $value-&gt;id; ?&gt;"&gt;&amp;nbsp; Mark As Read
                  &lt;/td&gt;
              &lt;/tr&gt;
              &lt;?php else: ?&gt;
                  &lt;tr class="w3-hover-text-red w3-text-black"&gt;
  
                      &lt;td&gt;
                      &lt;?php echo $value-&gt;from; ?&gt; 
                      &lt;/td&gt;
  
                      &lt;td&gt;
                      &lt;?php echo $value-&gt;subject; ?&gt;
                      &lt;/td&gt;
  
                      &lt;td&gt;
                          &lt;?php echo $value-&gt;message; ?&gt;
                      &lt;/td&gt;
  
                      &lt;td&gt;
                          &lt;?php echo $value-&gt;date_sent; ?&gt;
                      &lt;/td&gt;   
  
                      &lt;td&gt;
                          &lt;input type="checkbox" class="w3-check" onchange='markAsUnread(this);' id="&lt;?php echo $value-&gt;id; ?&gt;"&gt;&amp;nbsp; Mark As Unread
                      &lt;/td&gt;                           
                  &lt;/tr&gt;
                  &lt;?php 
                         endif;
                         endforeach;
                  ?&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>here are some screenshots of the problem I'm having:</p>
  
  <p><a href="https://i.stack.imgur.com/khTtW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/khTtW.png" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/rill5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rill5.png" alt="enter image description here"></a></p>
  
  <p>Any help would be appreciated, as I've been stuck on this issue for a few days and would like to figure out how to get it fixed.</p>