反转表行 [英] Invert table rows
本文介绍了反转表行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用jQuery反转表 tbody rows 。
I want to invert table tbody rows with jQuery.
我有什么:
<table width="630" border="0" cellspacing="0" cellpadding="0">
<thead>
<tr>
<td>TITLE A</td>
<td>TITLE B</td>
(...)继续jsfiddle。
(...) continue in jsfiddle.
这是我拥有的和我想要的: http://jsfiddle.net/ZaUrP/ 1 /
Here what I have and what I want: http://jsfiddle.net/ZaUrP/1/
推荐答案
与其他人差不多,只有我使用的是.detach()保持附加在 tr
上的任何疯狂事件。我还使用$ .makeArray来避免在基础jQuery对象上反转任何 proto
的东西。
pretty much the same as the other guy, only I use .detach() which is guarunteed to keep any crazy events that were attached to the tr
s intact. I also use $.makeArray to avoid reversing any of the proto
stuff on the base jQuery object.
$(function(){
$("tbody").each(function(elem,index){
var arr = $.makeArray($("tr",this).detach());
arr.reverse();
$(this).append(arr);
});
});
这篇关于反转表行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文