I need to write a Javascript function to swap the second column with the third column, we will open the console and write your function then call it to test.
index.html
<table style="margin:auto;" id="tabel1" class="mytabel" width="300" height="400" cellspacing="0" cellpadding="0"
border="1">
<tbody>
<tr>
<td> A1 </td>
<td> A2 </td>
<td> A3 </td>
</tr>
<tr>
<td> B1 </td>
<td> B2 </td>
<td> B3 </td>
</tr>
<tr>
<td> C1 </td>
<td> C2 </td>
<td> C3 </td>
</tr>
</tbody>
</table>
script.js ( so far )
function swap(){
//Write your code here
var tRows = document.getElementById('tabel1').children[0].children;
var column2 = [];
var column3 = [];
for(var i = 0; i < tRows.length; i++) {
column2[i] = tRows[i].children[1];
column3[i] = tRows[i].children[2];
}
console.log("cell2 " , column2);
console.log("cell3 " , column3);
}
swap();
