我现在有个PHP变量
var nodes = ;
里面的数据是这样的
var nodes = [{"id":"yc_36","label":"BING PIAN","color":"orange"},
{"id":"fj_16","label":"AN GONG JIANG YA WAN ","color":"red"},
{"id":"fj_17","label":"AN GONG NIU HUANG PIAN ","color":"red"},
{"id":"fj_19","label":"AN KANG XIN BAO WAN ","color":"red"},
{"id":"fj_28","label":"AN NAO NIU HUANG PIAN ","color":"red"},
{"id":"6693p_CYP3A4","label":"Aflatoxin activation and detoxification","color":"blue"},{"id":"6694p_CYP3A4","label":"Biosynthesis of maresin-like SPMs","color":"blue"}];
......
我想循环得到 所有 id 里面包含 fj这两个字符的 json 然后在后面都追加 key value -->"title ":"I have a popup!"
我这样不行,有点弱,求帮助~~谢谢
for (var i in nodes) {
var nihao = nodes[i].id
var wohao = nihao.substring(2, 0)
console.log(wohao);
if (wohao === "fj") {
nihao.title = "I have a popup!"
}
}