j0hnik,
танцы с бубном, но работает ...
<!DOCTYPE HTML>
<html>
<head><meta charset="utf-8">
<title>title</title>
</head>
<body>
<table>
<tr><td>1<td>2<td>3
<tr><td>4<td>5<td>6
<tr><td>7<td>8<td>9
</table>
___________________________________
<table>
<tr><td>1<td>2<td>3
<tr><td>4<td>5<td>6
</table>
___________________________________
<table>
<tr><td>1<td>2
<tr><td>3<td>4
<tr><td>5<td>6
<tr><td>7<td>8
</table>
<button>Клик</button>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
var n = 1;
$('button').click(function(){
n ^= 1;
$("table").each(function(){
var trs = $(this).find("tr");
var tds = $(this).find("td");
var t = trs.length;
var l = n ? tds.length/t : 1;
for (var k=0; k<l; k++) {
tds.each(function(i){
i = i % t;
trs.eq(i%t).append(this);
});
tds = $(this).find("td");
}
});
});
</script>
</body>
</html>