same th and td widths in different tables

same th and td widths in different tables

Hello,
Ia have two different tables that are generated from an application.
In the first one there are only <th> and the second one only <td>

I want the size of the first, second etc <td> to be equal to the corresponding <th>

I have managed to do that by putting ids in all of them and then make a function like:
      $(function(){
        takeHeight1 = $("#th1").width();
        $("#td1").width(takeHeight1);
        
        takeHeight2 = $("#th2").width();
        $("#td2").width(takeHeight2);
       });

But I would like to do it more automatic...like without ids for each td and th
Any ideas?

Thanks
k.