jquery json can each be used to do something like each where title='mytitle'
$.each(udt.Data, function(i, Data) {
$("#output").append("<h4>" + Data.productTitl开发者_如何学编程e + "</h4>");
});
I have the above code to loop through a json result what would be the best way to do something like for each Data where productTitle = 'product1'
You can try $.grep()
var arr = $.grep(udt.Data, function(Data, i){
return Data.productTitle === 'product1';
});
Example on jsfiddle
精彩评论