jquery 实现表格排序,大家能不能说一下思路呢?
看网上的插件,都是什么buletable,tablesorter,他们排序的时候,表格要有
thead,tbody。我的表格是没有tbody,thead,而且也加不上,请问,如何实现表格
的排序呢?
等待高手指点。

解决方案 »

  1.   

    LZ是想在表格内动态实现排序么?这个没研究过,有个插件flexigrid,挺好用的。。
      

  2.   

    呵呵,现在我需要是用jquery实现排序,在我说的情况下
      

  3.   

    刚才找了一下,还真是LZ说的情况,LZ看看jquery.tablesorter.js的代码吧,改成不需要thead和tbody的。
      

  4.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <base href="http://docs.jquery.com" />
    <script src="http://code.jquery.com/jquery-latest.js"></script>
     
    <script>
    window.onload = (function(){$("button").click(function(){
    var trS=$("table tr");
    for(var i=0;i<trS.length;i++){
    for(var j=i;j<trS.length;j++){
    if(trS[i].childNodes[0].innerText>trS[j].childNodes[0].innerText){
    $(trS[i]).insertAfter(trS[j]);
    }
    }
    }
    });
    });
    </script>
    <style> 
     
      table {
        background:#eeeeee;
      }
      
    </style>
    <style>html,body{border:0; margin:0; padding:0;}</style></head>
    <body>
    <table border="1">
        <tr><td>2</td></tr>
        <tr><td>1</td></tr>
        <tr><td>5</td></tr>
        <tr><td>4</td></tr>
    </table>
    <button>sort</button>
    </body>
    </html>
      

  5.   

    http://www.google.com/search?hl=en&source=hp&q=jquery+tablesorter&aq=f&aqi=g10&oq=
      

  6.   

    http://blog.csdn.net/heardy/archive/2010/12/31/6109233.aspx