gpt4 book ai didi

jquery - 如何通过 jQuery 在 内向上或向下移动 ?
转载 作者:行者123 更新时间:2023-11-30 23:52:53 28 4
gpt4 key购买 nike

执行此操作的优雅方法是什么?

最佳答案

这是我为您编写的一个快速插件。在表格上调用它,并为其指定旧行和新行位置。

$.fn.extend({ 
moveRow: function(oldPosition, newPosition) {
return this.each(function(){
var row = $(this).find('tr').eq(oldPosition).remove();
$(this).find('tr').eq(newPosition).before(row);
});
}
});

$('#myTable').moveRow(4, 3);

这是 jsbin 的示例:http://jsbin.com/uroyi

关于jquery - 如何通过 jQuery 在 <table> 内向上或向下移动 <tr> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1845600/

28 4 0