与其他人几乎相同,只有我使用 .detach() 来保证保持附加到 tr 的任何疯狂事件完整无缺.我还使用 $.makeArray 来避免反转基本 jQuery 对象上的任何 proto 内容.$(function(){$("tbody").each(function(elem,index){var arr = $.makeArray($("tr",this).detach());arr.reverse();$(this).append(arr);});});I want to invert table tbody rows with jQuery.WHAT I HAVE:<table width="630" border="0" cellspacing="0" cellpadding="0"><thead> <tr> <td>TITLE A</td> <td>TITLE B</td>(...) continue in jsfiddle.Here what I have and what I want: http://jsfiddle.net/ZaUrP/1/ 解决方案 fiddlepretty much the same as the other guy, only I use .detach() which is guarunteed to keep any crazy events that were attached to the trs 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); });}); 这篇关于反转表格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-31 02:31