私のprevious question私はページをロードする際にテーブルをソートしようとしていましたが、トグルスイッチをソートすることなくテーブルをソートしようとしていました。ページ。jQuery on pageロードソートは先行通貨記号でソートされません
質問に答えて、私はかなり良い反応を得て、問題を解決して眠りについたと思ったので、今日私のウェブサイトでコードを使用しようとすると、ソート技術は機能しません完全にjsfiddle https://jsfiddle.net/ghzch66e/12/で動作します。
ウェブページ上のデータには先頭の(£)記号https://jsfiddle.net/ghzch66e/13/が含まれているため、私は自分のウェブサイトでテーブルをソートしないことに気付きました。
どのように先頭の(£)記号で表の並べ替えを行うことができます。
jQuery(document).ready(function(e) {
var dataRows = [];
//Create an array of all rows with its value (this assumes that the amount is always a number. You should add error checking!! Also assumes that all rows are data rows, and that there are no header rows. Adjust selector appropriately.
$('#internalActivities > tbody > tr').each(function(i,j) {
dataRows.push({'amount': parseFloat($(this).find('.amount').text()), 'row': $(this)});
})
//Sort the data smallest to largest
dataRows.sort(function(a, b) {
return a.amount - b.amount;
});
//Remove existing table rows. This assumes that everything should be deleted, adjust selector if needed :).
$('#internalActivities').empty();
//Add rows back to table in the correct order.
dataRows.forEach(function(ele) {
$('#internalActivities').append(ele.row);
})
});
にそれを押したときに「」と「£」を交換してください。 –
これをチェックしましたか? http://stackoverflow.com/questions/22360440/how-to-ignore-and-characters-in-a-value-during-sort-comparison多分、シンボルをヌルに置き換えようとしますか?ちょうど推測。 – s0rfi949
http://stackoverflow.com/questions/23121437/sorting-an-array-in-javascript-85-88-dollars-9-35-95-96-126 – litel