javascript - Move Rows up and down in html table -
possible duplicate:
swapping rows in jquery
how move rows , down in table on button click?
try using jquery. can like:
<table id="mytable"> <tr> <td>row 1</td> <td><input type="button" value="move up" class="move up" /></td> <td><input type="button" value="move down" class="move down" /></td> </tr> ... </table> $('#mytable input.move').click(function() { var row = $(this).closest('tr'); if ($(this).hasclass('up')) row.prev().before(row); else row.next().after(row); });
look @ working here.
you can try jquery's sortable, much easier.
Comments
Post a Comment