@manhng

Welcome to my blog!

JavaScript Re-Order Table Rows Number

March 19, 2018 10:06

JavaScript Re-Order Table Rows Number

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_sort_table

<table>
<tr>
<td>3</td>
</tr>
<tr>
<td>1</td>
</tr>
<tr>
<td>2</td>
</tr>
</table>
Array.prototype.forEach.call(document.querySelectorAll('td:first-child'), function (elem, idx) {
    elem.innerHTML = idx + 1;
});

Categories

Recent posts