js遍历某一列json数据和

varJosnInfo={"sites":[{"title":"批次数量","Field":"pcsl","ReadOnly":"readonly='readonly'"... var JosnInfo = { "sites": [
{ "title": "批次数量",
"Field": "pcsl",
"ReadOnly": "readonly='readonly'",
"Hidetd": "true",
"tdEvent": " onclick='openPC(this)'",
"tdClass": "tdspbh",
"txtAlign": ""
},
{ "title": "编号",
"Field": "spbh",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " ",
"tdClass": "tdspbh",
"txtAlign": ""
},
{ "title": "名称",
"Field": "spmc",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdspmc",
"txtAlign": ""
},
{ "title": "规格",
"Field": "ggxh",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdggxh",
"txtAlign": ""
},
{ "title": "产地",
"Field": "spcd",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdcd",
"txtAlign": ""
},
{ "title": "单位",
"Field": "spdw",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tddw",
"txtAlign": "text-align:center;"
},
{ "title": "数量",
"Field": "spsl",
"ReadOnly": "",
"Hidetd": "false",
"tdEvent": " onpaste='return false' onkeydown='return check(event)' onkeydown='SXZY(this)' onblur='sl_onblur(this)' ",
"tdClass": "tdsl",
"txtAlign": "text-align:right;"
},
{ "title": "单价",
"Field": "spdj",
"ReadOnly": "",
"Hidetd": "false",
"tdEvent": " onpaste='return false' onkeydown='return check(event)' onkeydown='SXZY(this)' onblur='dj_onblur(this)'",
"tdClass": "tddj",
"txtAlign": "text-align:right;"
}
]

}
本人小白刚入公司 各位大神帮忙 遍历一下单价并求和 在线等 急急急!!
展开
 我来答
a1104054723
2018-07-29 · TA获得超过190个赞
知道小有建树答主
回答量:562
采纳率:64%
帮助的人:237万
展开全部

用JS原生的方法即可,不过没在JSON上看到数值啊,我帮你取到了数组,剩下的自己操作下就可以了。

<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>

<body>
<div id="box"></div>
<img name="text"></img>
<script>
var JosnInfo = {
"sites": [{
"title": "批次数量",
"Field": "pcsl",
"ReadOnly": "readonly='readonly'",
"Hidetd": "true",
"tdEvent": " onclick='openPC(this)'",
"tdClass": "tdspbh",
"txtAlign": ""
},
{
"title": "编号",
"Field": "spbh",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " ",
"tdClass": "tdspbh",
"txtAlign": ""
},
{
"title": "名称",
"Field": "spmc",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdspmc",
"txtAlign": ""
},
{
"title": "规格",
"Field": "ggxh",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdggxh",
"txtAlign": ""
},
{
"title": "产地",
"Field": "spcd",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tdcd",
"txtAlign": ""
},
{
"title": "单位",
"Field": "spdw",
"ReadOnly": "readonly='readonly'",
"Hidetd": "false",
"tdEvent": " onkeydown='SXZY(this)' ",
"tdClass": "tddw",
"txtAlign": "text-align:center;"
},
{
"title": "数量",
"Field": "spsl",
"ReadOnly": "",
"Hidetd": "false",
"tdEvent": " onpaste='return false' onkeydown='return check(event)' onkeydown='SXZY(this)' onblur='sl_onblur(this)' ",
"tdClass": "tdsl",
"txtAlign": "text-align:right;"
},
{
"title": "单价",
"Field": "spdj",
"ReadOnly": "",
"Hidetd": "false",
"tdEvent": " onpaste='return false' onkeydown='return check(event)' onkeydown='SXZY(this)' onblur='dj_onblur(this)'",
"tdClass": "tddj",
"txtAlign": "text-align:right;"
}
]

};

JosnInfo = JSON.stringify(JosnInfo);
var text = JSON.parse(JosnInfo);
console.log(text.sites);
</script>
</body>

</html>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式