- $(function($){
- //元素交换
- $(".up").live('click',function(){
- $(this).parent().parent().prev("tr").before($(this).parent().parent());
- });
- $(".down").live('click',function(){
- $(this).parent().parent().next("tr").after($(this).parent().parent());
- });
- $(".delete").live('click',function(){
- $(this).parent().parent().remove();
- });
- $(".add").live('click',function(){
- $('<tr id="'+(i++)+'"><td>'+(i)+'</td><td><input type ="button" value="上" class="up"/><input type ="button" value="下" class="down"/><input type ="button" value="删" class="delete"/><input type ="button" value="加" class="add"/></td></tr>')
- .insertAfter($(this).parent().parent());
- });
- });
- <table width="100" height="100" id="table" border="1">
- <tr id="1">
- <td>1</td><td>
- <input class="up" type="button" value="上">
- <input class="down" type="button" value="下">
- <input class="delete" type="button" value="删">
- <input class="add" type="button" value="加">
- </td>
- </tr>
- </table>