JSFiddle - React, Tailwind, and code Playground

by TCHdevlp

HTML

<div id="mainDiv">
    <table id="oldTable" class="classtable">
        <tr>
            <th>A</th>
            <th>B</th>
            <th>C</th>
            <th>D</th>
            <th>E</th>
            <th>F</th>
        </tr>
        <tr>
            <td>a1</td>
            <td>b1</td>
            <td>c1</td>
            <td>d1</td>
            <td>e1</td>
            <td>f1</td>
        </tr>
        <tr>
            <td>a2</td>
            <td>b2</td>
            <td>c2</td>
            <td>d2</td>
            <td>e2</td>
            <td>f2</td>
        </tr>
        <tr>
            <td>a3</td>
            <td>b3</td>
            <td>c3</td>
            <td>d3</td>
            <td>e3</td>
            <td>f3</td>
        </tr>
    </table>
</div>
<div id="divResult">
</div>

CSS

.classtable, .classtable td, .classtable th{
    border:solid 1px #bbb;
}
.classtable th{
    font-weight:bold;
    color:navy;
}

JavaScript

var arrayPositions = new Array(4,5,6,1,2,3); // correspond Ă  : 4 5 6 1 2 3
                      //ajout d'identifiants virtuels sur les colonnes (oui, je triche)
                        var i =1;
                      $('#oldTable th').each(function(){
                          $(this).prop('id',i++);
                     });
var newTable = $('<table></table>');
    //boucle sur l'arrayposition
for (j=0; j<arrayPositions.length; ++j){
    var column = $("#oldTable tr > :nth-child("+arrayPositions[j]+")");
    alert (column.text());

}