开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜