如何使用jQuery(或CSS)按列对HTML表进行排序?
我希望能够获取HTML表格,例如:
translate.com & https://translate.google.com Bing Translator I eat tacos Yo como tacos Comer tacos I will eat a taco Voy a comer un taco Me voy a comer un taco I will eat tacos Voy a comer tacos Me voy a comer tacos I would eat a taco Me volvería a comer un taco Comer un taco I would eat tacos Me volvería a comer tacos Comer tacos I am eating a taco Me estoy comiendo un taco Estoy comiendo un taco I am eating tacos Estoy comiendo tacos Voy a comer tacos . . . They were eating tacos Estaban comiendo tacos Estaban comiendo tacos
(或任何HTML表)并允许在单击列时对其进行排序。
无论是jQuery还是CSS解决方案都可以。
jQuery Table Sorter( http://tablesorter.com/docs/ )可以使用。 有许多不同的jQuery插件来处理这个问题。 如果尚未使用jQuery,那么也有纯Javascript选项。
33 Javascript桌面排序解决方案( http://tympanus.net/codrops/2009/10/03/33-javascript-solutions-for-sorting-tables/ )。
CSS无法对数据进行排序; 必须使用Javascript。