这是在一个方向上排序,但不是在另一个方向上。桌子的规格有什么问题吗?如果有人能发布一个HTML示例,在包含逗号的美元值列上进行双向排序,那就太好了。
// create sorter
<script type="text/javascript" id="js">
$(document).ready(function() {
// call the tablesorter plugin
$("table.tablesorter").tablesorter({
// enable debug mode
debug: false
});
});
</script>不确定此处是否需要前缀(table.tablesorter):
// add parser through the tablesorter addParser method
<script type="text/javascript" id="js">
$.tablesorter.addParser({
// set a unique id
id: 'money',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s) {
return s.toLowerCase().replace("\$","").replace(",","");
},
// set type, either numeric or text
type: 'numeric'
});不确定此处是否需要table.tablesorter:
// specify column
$(function() {
$("table.tablesorter").tablesorter({
headers: {
// column to be handled specially
7: {
sorter:'money'
}
}
});
});
</script>下面是表格的顶部:
<table cellspacing="1" class="tablesorter">
<thead>
<tr>
<th>Name</th>
<th>Major</th>
<th>Gender</th>
<th>English</th>
<th>Japanese</th>
<th>Calculus</th>
<th>Overall grades</th>
<th>Money</th>
</tr>
</thead>
<tbody>
<tr>
<td>Student01</td>
<td>Languages</td>
<td>male</td>
<td>80</td>
<td>70</td>
<td>75</td>
<td>bad</td>
<td>$1.00</td>
</tr> 发布于 2012-03-07 05:21:51
由于您使用的是数字,因此需要将字符串解析为实数。在解析器中更改这一行:
format: function(s) {
return parseFloat( s.toLowerCase().replace("\$","").replace(",","") );
}https://stackoverflow.com/questions/9122839
复制相似问题