码迷,mamicode.com
首页 > 编程语言 > 详细

juery中循环遍历json数组

时间:2016-03-24 19:59:23      阅读:316      评论:0      收藏:0      [点我收藏+]

标签:

       var  dataList=[];     
       var stock0={stockcode:"007758",stockname:"商业政7",state:"1"};
            var stock1={stockcode:"006658",stockname:"材料政8",state:"1"};
            var stock2={stockcode:"023758",stockname:"深发政9",state:"1"};
            var stock3={stockcode:"007368",stockname:"思迪政10",state:"1"};
            var stock4={stockcode:"033358",stockname:"指数政11",state:"1"};
            dataList.push(stock0);
            dataList.push(stock1);
            dataList.push(stock2);
            dataList.push(stock3);
            dataList.push(stock4);

       var code="033358";
       

       for(var i=0,l=dataList.length;i<l;i++)
       {  
          
           if(dataList[i][‘stockcode‘].indexOf(code) != -1)
           {
         //遍历对象内所有值
         //for(var key in dataList[i])
         //{alert(key+dataList1[i][key]);
         //}
        //遍历对象其中的一个值
              dataList[i][‘state‘]="<span>已添加</span>";
              dataList.push(dataList[i]);
             //  alert("已经添加!"+dataList1[i][‘stockname‘]);
              layerUtils.iAlert("添加成功!",0);
           }
         }

 

juery中循环遍历json数组

标签:

原文地址:http://www.cnblogs.com/wangzhuxing/p/5316604.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!