2012-10-14 46 views
0

我有一個插件(https://github.com/bjorn2404/jQuery-Store-Locator-Plugin)創建與代碼多維數組:篩選多dimenisonal陣列的jquery

 
locationset[i] = new Array (distance, name, lat, lng, address, address2, city, state, postal, phone, web, hours1, hours2, hours3); 
i++; 

我需要根據距離過濾它(假設它應該小於10)。

有沒有辦法做到這一點?

謝謝!

+1

使用[jQuery.grep](http://api.jquery.com/jQuery.grep/) –

回答

0
var filtered_array = $.grep(locationset, function(value) { 
    return value[0] < 10; 
}); 

您應該使用grep,因爲這就是它的設計目的。