weixin_33728268 2013-07-16 06:57 采纳率: 0%
浏览 18

从JSON数组获取价值

My JSON currently looks like this:

 {
  "overview" : {
    "title" : "Blog"
  },

  "item" : {
    "title" : "Hello World"
  }

 }

My jQuery looks like this:

<script type="text/javascript">

$(document).ready(function(){

      $.getJSON(url, function(obj) {

        $.each(obj, function(key, value){

          $('.image-slide-title').append(value.title);

        });

      });

});

</script>

All works perfectly fine except the HTML markup is showing:

<div class="image-slide-title">Blog Hello World</div>

I just want it to skip the overview key/value and just go right to the item key/value so at the end of the day it looks like:

 <div class="image-slide-title">Hello World</div>
  • 写回答

1条回答 默认 最新

  • weixin_33694172 2013-07-16 07:00
    关注

    You could then loop through the obj.item properties:

    for (var prop in obj.item) {
       var value = obj.item[prop];
       $('.image-slide-title').append(value);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站