javascript - Swap multiple rows at same time using Jquery -
i have list of items , want set order of items in list. if select multiple items @ same multiple items should move respectively or down.
i using code move , down. in case if first , third item selected returns false because adding check if previous current item null should not move , if next current not available should not move down.
$('#selectedtab tr').each(function () { var currenttr = $(this).find('td.backgroundcolor').parent(); if (currenttr.text() == null) { } else { debugger; var previoustr = ""; if (obj.value == "move up") { previoustr = currenttr.prev(); //if (previoustr.length == 0) // return false; } else { previoustr = currenttr.next(); if (previoustr.length == 0) return false; } var temp = currenttr.contents().detach(); currenttr.append(previoustr.contents()); previoustr.append(temp); } });
and html
`
<table id="unselectedtab" style="width: 100%"> <tr> <td> <img src="~/images/employees.png" />employee</td> </tr> <tr> <td> <img src="~/images/vehicles.png" />vehicle</td> </tr> <tr> <td> <img src="~/images/collision.png" />collision</td> </tr> <tr> <td> <img src="~/images/trailers.png" />trailers</td> </tr> <tr> <td> <img src="~/images/dispatch.png" />dispatch</td> </tr> <tr> <td> <img src="~/images/notifications.png" />notifications</td> </tr> <tr> <td> <img src="~/images/equipment.png" />equipment</td> </tr> </table> </td>
`
thanks prince chopra
Comments
Post a Comment