JSFiddle - React, Tailwind, and code Playground

by Ish Kumar

HTML

<table>
    <tr>
        <th> Header1 </th>
        <th> Header2 </th>
        <th> Header3 </th>
    </tr>
    <tr>
        <td> Value 1,1 </td>
        <td> Value 2,1 </td>
        <td> Value 3,1 </td>
    </tr>
    <tr>
        <td> Value 1,2 </td>
        <td> Value 2,2 </td>
        <td> Value 3,2 </td>
    </tr>
</table>

JavaScript

var data = Array();
    data[0] = Array();
    data[0][1] = Array();
    data[1] = Array();
    

$("table tr").each(function(i, v){
    data[1][i] = Array();
    $(this).children('th').each(function(ii, vv){
        data[0][1][ii] = $(this).text();
    });  
                       
    $(this).children('td').each(function(ii, vv){
        data[1][i][ii] = $(this).text();
    }); 
})