开发者

Is there a way to rotate an html table?

Is there a way to rotate an html table? So, say I had a table like this:

  <table id="table-1" cellspacing="0" cellpadding="2">
        <tr><td>1</td></tr>
        <tr><td>2</td></tr>
        <tr><td开发者_高级运维>3</td></tr>
        <tr><td>4</td></tr>
        <tr><td>5</td></tr>
        <tr><td>6</td></tr>
    </table>

and wanted to some sort of button that had javascript behind it that could rotate the table any which direction. For example, clicking the right button, results in:

  <table id="table-1" cellspacing="0" cellpadding="2">
        <tr><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td></tr>
    </table>

I have a drag and drop plugin that uses a table, and I am trying to do a piece that allows for a user to add to a queue (that results in the table), and then they can also rotate it around as well. Thanks.


How about something like this?

    var len = $('#table-1 tr').length;
    var $first = $('#table-1 tr').eq(0);
    for(var i = 1; i < len; i++) {
        $('#table-1 tr').eq(1).find('td').prependTo($first);
        $('#table-1 tr').eq(1).remove();
    }

http://jsfiddle.net/LLknJ/


There is TableSorter plugin.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜