我有一个 10 列的 html 表(即 1 2 3 4 5 6 7 8 9 10 ),我想使用 Jquery 水平翻转列(即 10 9 8 7 6 5 4 3 2 1 )...
我有下面的代码,但是这段代码很长,任何人都可以为此提供短代码。
$(function() {
jQuery.each($("table tr"), function() {
$(this).children(":eq(9)").after($(this).children(":eq(0)"));
$(this).children(":eq(8)").after($(this).children(":eq(0)"));
$(this).children(":eq(7)").after($(this).children(":eq(0)"));
$(this).children(":eq(6)").after($(this).children(":eq(0)"));
$(this).children(":eq(5)").after($(this).children(":eq(0)"));
$(this).children(":eq(4)").after($(this).children(":eq(0)"));
$(this).children(":eq(3)").after($(this).children(":eq(0)"));
$(this).children(":eq(2)").after($(this).children(":eq(0)"));
$(this).children(":eq(1)").after($(this).children(":eq(0)"));
});
});
Run Code Online (Sandbox Code Playgroud)