用jQuery排序表 [英] Sort table with jQuery

查看:87
本文介绍了用jQuery排序表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery对 foreach 循环进行排序?我会在 id 上进行排序,但我现在不知道该怎么做。

How can I sort this foreach loop with jQuery? I will sort on id but I don't now how to do that.

   <form id="fileForm" action="#" enctype="multipart/form-data" method="get">
       <table cellpadding="2" cellspacing="0" width="100%" class="grid">
            <tr>
                <th>ID:</th>
                <th>Time:</th>
                <th>Location:</th>
                <th>From IP:</th>
                <th>Title (url):</th>
                <th></th>
            </tr>
            <tr>
                 <td>1</td>
                 <td>12:00</td>
                 <td>Utrecht</td>
                 <td>192.019.192.00</td>
                 <td>site</td>
            </tr>
       </table>
  </form>


推荐答案

http://datatables.net/ - 是一个客户端的JQuery插件,它可以让您对PHP呈现的最终HTML进行排序/分页等。

http://datatables.net/ - is a client side JQuery plugin which will allow you to sort/paginate etc the final HTML that your PHP renders.

我会倾向于使用服务器端解决方案,但是如果您在1000行的行上有1000个时间,则初始呈现页面所需的时间将非常长。

I would tend to use a server-side solution though if you have 1000s upon 1000s of rows as the time it takes to initially render the page would be very long.

这篇关于用jQuery排序表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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