1. 程式人生 > >Jquery 常用的幾個過濾數據函數

Jquery 常用的幾個過濾數據函數

ext 測試 grep 數據 fun clas func his pan

$.grep 數據篩選

var j=2017; 
var data=[{year:"2017",name:"測試1"},{year:"2017",name:"測試2"},{year:"2016",name:"測試2"},{year:"2015",name:"測試2"}] 

var thisData = $.grep(data,
function (n)
{
return Number(n.Year) ===j; }
);

$.each 數據遍歷

var data=[{year:"2017",name:"測試1"},{year:"2017",name:"測試2"},{year:"2016",name:"測試2"},{year:"2015",name:"測試2"}] 
var strText=""; $.each(data, function (i, n) { strText+=n.name+" "; });

//待續。。。

Jquery 常用的幾個過濾數據函數