JSFiddle - React, Tailwind, and code Playground

by Aaron von Schassen

HTML

<table class="table1" border="1">
  <tr>
    <td class="id-1">1</td>
    <td>Name</td>
  </tr>
  <tr>
    <td class="id-2">2</td>
    <td>Name 2</td>
  </tr>
</table>

<table class="table2" border="1">
  <tr>
    <td class="id-1">1</td>
    <td>2019</td>
  </tr>
  <tr>
    <td class="id-2">2</td>
    <td>2018</td>
  </tr>
</table>

JavaScript

$('.table1 tr td:first-child').each(function() {
   var firstTableClass = $(this).attr('class');
   $('.table2 tr td:first-child').each(function() {
     if ($(this).attr('class') === firstTableClass) {
       $(this).html($('.table1 tr td:last-child').html());
     }
   });
 });