【发布时间】:2012-11-02 19:50:38
【问题描述】:
我有这样的html表结构:
<table cellpadding="0" cellspasing="0" class="tablesorter zebra" id="articles-table">
<tbody>...etc standart stuff...
<tr>
<td>
</td>
</tr>
then i have
<tr id="123123">
<td colspan="7">
Analogs
</td>
</tr>
<tr id="prcol">
<td>
<td>
</td>
</td>
<tr>
...
</table>
我试过这样的脚本:
jQuery(function($) {
var table = $('table');
$(document).ready(function () {
$('#prcol')
.each(function(){
var th = $(this),
thIndex = th.index(),
inverse = false;
th.click(function(){
table.find('td').filter(function(){
return $(this).index() === thIndex;
}).sortElements(function(a, b){
return $.text([a]) > $.text([b]) ?
inverse ? -1 : 1
: inverse ? 1 : -1;
}, function(){
return this.parentNode;
});
inverse = !inverse;
});
});
});
});
但主要问题是它正在对所有内容进行排序......但我只需要那个,它会在我的 tr 之后使用id 123123 并在页面加载时排序......
我需要通过我的浮点数进行排序,它只在第二个 div 中!在 id = 123 的 tr 中,这很重要...而且我在 web 中看到的所有解决方案都非常庞大...我只需要在具有特定 id 的某些 tr 中进行简单的排序第二个 td ...我该如何解决?
我试过 tablesorter.com。但它不是我...
也在这里尝试#2: link
第一行还有麻烦...
【问题讨论】:
-
很抱歉,如果它没有帮助..认为它做了类似的事情..
-
如果我们能看到一个起始表是什么样子的例子,以及排序后的表应该是什么样子,那将会非常有帮助。
-
@slashingweapon 查看小提琴...我只需要通过价格 (цена) td's 进行排序
-
@slashingweapon 所以根据 jsfiddle 首先在 tbody.analogs_Art 必须是 tr 价格为 3.36,然后是 3.62、3.99 和 6.14 在顶部...其他在底部的 td 价格中没有文字(问题在这里stackoverflow.com/questions/13387394/…)
标签: jquery html ruby-on-rails jquery-ui-sortable