Is there a way to rotate an html table?

跟風遠走 提交于 2019-12-10 16:34:39

问题


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.


回答1:


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/




回答2:


There is TableSorter plugin.



来源:https://stackoverflow.com/questions/2754752/is-there-a-way-to-rotate-an-html-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!