js循环出json数据中字段为 dlmc 的所有值,如何表示
varDL_Data={result:[{'fenleiName':'滚珠丝杠Ⅱ','num':'2065','dlmc':'传动件'},{'fenleiName':'滚...
var DL_Data={result:[
{'fenleiName':'滚珠丝杠Ⅱ ','num':'2065','dlmc':'传动件'},
{'fenleiName':'滚珠丝杠Ⅰ','num':'62','dlmc':'传动件'},
{'fenleiName':'密封圈','num':'63','dlmc':'密封'},
{'fenleiName':'直线导轨各系列','num':'476','dlmc':'导轨'}]}
function dlData(data,pid,type)//大类
{
str="";
jQuery.each(data.result,function(i,n){
var url = "";
str += "<a href=\""+url+"\" target='_blank'>"+n.fenleiName+"</a>";
})
jQuery("#"+pid+" p").html(str);
} 展开
{'fenleiName':'滚珠丝杠Ⅱ ','num':'2065','dlmc':'传动件'},
{'fenleiName':'滚珠丝杠Ⅰ','num':'62','dlmc':'传动件'},
{'fenleiName':'密封圈','num':'63','dlmc':'密封'},
{'fenleiName':'直线导轨各系列','num':'476','dlmc':'导轨'}]}
function dlData(data,pid,type)//大类
{
str="";
jQuery.each(data.result,function(i,n){
var url = "";
str += "<a href=\""+url+"\" target='_blank'>"+n.fenleiName+"</a>";
})
jQuery("#"+pid+" p").html(str);
} 展开
1个回答
展开全部
像这样:
var result = DL_Data.result;
for(var i = 0;i < result.length;i++){
var dlmc = result[i].dlmc;
alert(dlmc);
}
var result = DL_Data.result;
for(var i = 0;i < result.length;i++){
var dlmc = result[i].dlmc;
alert(dlmc);
}
更多追问追答
追问
谢谢,再请教一下,我想按照 dlmc这个来分别输出fenleiName
这个的值,怎么循环呢。比如dlmc=传动件,输出fenleiName值为滚珠丝杠Ⅱ和滚珠丝杠Ⅰ; dlmc=密封,fenleiName值为密封圈。以dlmc来分组
追答
你具体要做个什么?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询