JSFiddle - React, Tailwind, and code Playground
by TrueBlueAussie
HTML
<table>
<thead>
<tr>
<th>Heading 1</th>
<th>Heading 2</th>
<th>Heading 3</th>
</tr>
</thead>
<tbody>
<tr>
<td>Lorem</td>
<td>lipsum</td>
<td>dolor</td>
</tr>
<tr>
<td>Lorem</td>
<td>lipsum</td>
<td>dolor</td>
</tr>
<tr>
<td>Lorem</td>
<td>lipsum</td>
<td>dolor</td>
</tr>
</tbody>
</table>
JavaScript
var $th = $("thead th");
var $tr = $("tbody tr");
$th.each(function(index){
$tr.find('td:nth-child(' + index + ')').attr('data-attr', $(this).text());
});