jquery实现表格的上移、下移、增加、删除
- $(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>
相关推荐
today0 2020-09-22
89520292 2020-09-18
周公周金桥 2020-09-06
bigname 2020-08-25
灵均兰草 2020-08-20
hannuotayouxi 2020-08-20
ChinaWin 2020-08-13
大象从不倒下 2020-07-31
好好学习天天 2020-07-28
powrexly 2020-07-20
AlisaClass 2020-07-19
88530091 2020-07-14
WebVincent 2020-07-09
骆驼的自白 2020-06-26
lanzhusiyu 2020-06-21
Phoebe的学习天地 2020-06-21
诗蕊 2020-06-14
jiedinghui 2020-05-30