【发布时间】:2013-07-05 10:10:56
【问题描述】:
我有这个数组:
[{
"title": "Pirates of the Caribbean 5",
"others": "lorem",
"tags": "action,experimental,comedy"
},
{
"title": "Toy Story 3",
"others": "lorem",
"tags": "animation,family,comedy"
},
{
"title": "Pirates of the Caribbean 1",
"others": "lorem",
"tags": "action,adventure,comedy"
}]
和我正在尝试获取标签为action的所有详细信息(标题、其他)。
要查找字符串是否包含操作,我这样做:
$.getJSON('jsonpath.json', function(data) {
var items = [];
$.each(data, function(count,item) {
var a = $.inArray("action", item.tags.split(","));
if (a != -1){
console.log("Found")
}
});
});
在此处附加/解析带有动作标签的电影的标题和其他电影之后,我该怎么做?
【问题讨论】: