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);
    }
    
    评论

报告相同问题?