AFAIK, es gibt keine magische Lösung, um dies umzuschalten. Was eine Drehung (90 Grad) betrifft, würde das wahrscheinlich den ganzen Tisch zur Seite drehen, ähnlich wie ein Blatt Papier aussehen würde, wenn Sie um 90 Grad gedreht wären, und das ist nicht das, was Sie wollen (denke ich?).
Wenn das möglich (und realistisch) ist, würde ich vorschlagen, es im HTML selbst zu ändern.
Wie in den Kommentaren angegeben, gibt es keinen Hinweis darauf, hier, hier ist also eine grundlegende Javascript Alternative [auch wenn dies nicht das, was Sie ist suchen] jQuery verwenden. Ohne Ihre Erfahrung zu kennen, habe ich mir die Zeit genommen, alles zu kommentieren, um sicher zu sein, dass Sie verstehen, was der Code macht.
// Change the selector to suit your needs
$('table').each(function(){
var table = $(this), // Reference each table in the page
header = $('thead', table), // Reference the table head
headings = []; // Set an array for each column
// If the table doesn't have a header, use it's footer for column titles
if(!header.length)
header = $('tfoot', table);
// If there's no header nor footer, skip to the next table
if(!header.length)
continue;
// Loop each heading to get the header value
$('th', header).each(function(){
var heading = $(this).html(); // Each heading value content, including any HTML; use .text() to use the text only
headings.push(heading); // Add heading value to array
});
// Make sure the content is wrapped in a tbody element for proper syntax
if(!$('tbody', table).length)
table.wrapInner('<tbody></tbody>');
// Set counter to reference the heading in the headings array
var x = 0;
// Loop through each row in the table
$('tbody tr').each(function(){
var row = $(this),
label = headings[x];
// Add the heading to the row, as a <th> for visual cues (default: bold)
row.prepend('<th>'+label+'</th>')
// Move to the next value in the headings value
x++;
});
});
siehe die bearbeitete Geige http://jsfiddle.net/w5nWG/1/. Ich will das nicht – vishesh
@vishesh, also wollen Sie Ihre Tabelle nach DOM-fähig transponieren? versuchen Sie dies https://gist.github.com/pgaertig/2376975 – sebastian
das tat es.danke – vishesh