0
我有此數組:的Javascript:獲取其中數組中的特定值包含文字(標籤)的陣列
[{
"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"
}]
和我試圖讓所有的細節(標題,其他),其中標籤是動作。
要查找一個字符串是否包含動作我這樣做:
$.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")
}
});
});
我該怎麼辦這裏後追加/解析電影的標題的和其它的標記作用?
我想追加所有帶標籤動作的標題。這就是全部 – jQuerybeast
對不起,這基本上是一個錯誤的問題。感覺有點累。請標記爲關閉。 – jQuerybeast