-
-
Save pepebe/3215081 to your computer and use it in GitHub Desktop.
JS: Transpose HTML table using jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2do: Have to check this one in the nex few days