Skip to content

Instantly share code, notes, and snippets.

@pepebe
Forked from pgaertig/transpose_table.js
Created July 31, 2012 08:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pepebe/3215081 to your computer and use it in GitHub Desktop.
Save pepebe/3215081 to your computer and use it in GitHub Desktop.
JS: Transpose HTML table using jQuery
$(function() {
var t = $('#thetable tbody').eq(0);
var r = t.find('tr');
var cols= r.length;
var rows= r.eq(0).find('td').length;
var cell, next, tem, i = 0;
var tb= $('<tbody></tbody>');
while(i<rows){
cell= 0;
tem= $('<tr></tr>');
while(cell<cols){
next= r.eq(cell++).find('td').eq(0);
tem.append(next);
}
tb.append(tem);
++i;
}
$('#thetable').append(tb);
$('#thetable').show();
}
@pepebe
Copy link
Author

pepebe commented Jul 31, 2012

2do: Have to check this one in the nex few days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment