<分区>
Possible Duplicate:
Swapping rows in JQuery
如何在点击某个按钮时在表格中上下移动行?
标签 javascript html
最佳答案
尝试使用 jQuery。你可以这样做:
<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);
});
看看它在工作 here .
您也可以试试 jQuery 的 sortable , 它是 much easier .
关于javascript - 在html表格中上下移动行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4321320/
相关文章:
javascript - 类型错误 : Value can't be converted to a dictionary
javascript - 在 CSS .style.transform 函数中,我试图将度数添加为 90 + MenuRotate,这是一个变量
javascript - jCrop 在某些浏览器上无法首次初始化裁剪
javascript - ng-hide 在按下提交按钮时隐藏数据
javascript - 无法从未定义中读取属性 "namedValues"
javascript - 当使用 2 种语言时,如何使用 css 反转一种语言的单词顺序?