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;"
}
]
}
本人小白刚入公司 各位大神帮忙 遍历一下单价并求和 在线等 急急急!! 展开
{ "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;"
}
]
}
本人小白刚入公司 各位大神帮忙 遍历一下单价并求和 在线等 急急急!! 展开
1个回答
展开全部
用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>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询