有没有办法旋转html表? [英] Is there a way to rotate an html table?

查看:86
本文介绍了有没有办法旋转html表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法旋转html表?所以说我有这样的表:


 < table id =table-1 cellspacing =0cellpadding =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>


,并希望有一些JavaScript背后的按钮可以在任何方向旋转桌子。例如,点击右边的按钮会导致:


 < table id =table- 1cellspacing =0cellpadding =2> 
< tr>< td> 6< / td>< td> 5< / td>< td> 4< / td>< td> 3< / td>< td& / TD>< TD→1< / TD>< / TR>
< / table>


我有一个使用表的拖放插件,我试图做一个允许用户添加到队列中(这导致表中)的部分,然后它们也可以旋转它。谢谢。

解决方案

这样的东西怎么样?

  var len = $('#table-1 tr')。length; 
var $ first = $('#table-1 tr')。eq(0); $($ i $)$($ i $)$($ i $)$($ i $)
);
$('#table-1 tr')。eq(1).remove();
}

http://jsfiddle.net/LLknJ/


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/

这篇关于有没有办法旋转html表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆