js往列表头部添加json_如何往指定是json数组里面添加数据

我现在有个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!"

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值