Below is an example of a basic table:
table, th, td {
border: 1px black solid;
border-collapse: collapse;
}
<table>
<tr>
<th>number</th>
<th>name</th>
<th>id</th>
</tr>
<tr>
<td>1</td>
<td>red</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>blue</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>yellow</td>
<td>3</td>
</tr>
</table>
I am looking to implement a feature that allows drag and drop functionality in the table. When an item is moved from one position to another, I want its number to change to match the position it was moved to, while keeping the name and id unchanged. For instance, if "blue" is moved to the first spot, its number should become 1 while its id remains 2, and similarly for other items. The overall goal is to maintain consistency in the table while allowing for reordering through drag and drop.
Any suggestions on how I can achieve this?