テーブルが1つあり、テーブルの行の値が4、2、2、4、5、4のように、テーブルの列データの一意の値が必要です。このdata = [ 2 , 4 , 5 ]
テーブルの列と並べ替えの配列から一意のデータを取得
ように私は
http://jsbin.com/ojeroc/5/edit#source
リンク
以下のように、この使用してjQueryのを達成することができています。しかし、私は別の関数で、この配列を使用することができますので、データを昇順に来る必要があります。$(document).ready(function(){
console.log("document is ready");
var items=[], options=[];
console.log(items);
console.log(options);
//Iterate all td's in second column
$('#dataTable tr td').each(function(){
//console.log("Inside tr data");
//add item to array
items.push($(this).text());
// console.log($(this).text());
});
//restrict array to unique items
var items = $.unique(items);
alert(items);
});
ありがとう、私はソートされた配列の最小値と最大値を取得したい、それを行うことができますか? – Wazdesign
@Wazdesignあなたが一秒間考えるなら、それは簡単だとわかるでしょう。 – kapa
ソート後、 'sortedItems [0]'はあなたにminと 'sortedItems [sortedItems.length-1]'を与えます。 –