I have a HTML table with following content.
<table class='main'>
<tr id='r1' class='tbl'>
<td>V1</td>
</tr>
<tr id='r2' class='tbl'>
<td>V2</td>
</tr>
<tr id='r3' class='tbl'>
<td>V3</td>
</tr>
<tr id='r4' class='tbl'>
<td>V4</td>
</tr>
<tr id='r5' class='tbl'>
<td>V5</td>
</tr>
</table>
I can select a row by using jQuery code.
When I press “up” button in html, I want to swap the value of selected row’s html with previous row.
Is it possible by using jQuery? I’ve tried several methods, but none of them is working.
I recently had to do this for a project. Here’s the code. Modify for your use.
jQuery:
This snippit also includes the ability to add rows, which can easily be removed.
Mainly pay attention to the $(‘.row_up’) and $(‘.row_down’) to see how to move the rows around using jquery and an image/object with class row_up and row_down — This concept will help you write a custom solution for your project