关于此链接:http://jsfiddle.net/De8Ku/1477/如何开发代码以便我可以按评级进行排序?
var vA = parseInt($(keySelector, a).text().replace("$",''));
var vB = parseInt($(keySelector, b).text().replace("$",''));
return (vA < vB) ? -1 : (vA > vB) ? 1 : 0;
答案 0 :(得分:0)
添加一些评分,例如......
<a href="#">
<span class="alpha">D</span>
<span class="price">$35</span>
<span class="rating">1.3</span>
</a>
添加链接...
<li>
<a href="#" id="sRating" class="btnSort">
Rating
</a>
</li>
向链接添加数据属性,告诉它按选择器span.rating
...
$('#sRating').data("sortKey", "span.rating");