How to get HTML elements, content or parameters from JSON object

This question already has an answer here:

  • Safely turning a JSON string into an object 22 answers

  • try using

    result.rss.channel.item[0].description
    

    because from the example it looks like item is an array of objects.


    You can do this with jQuery.

    var $div = $('<div/>').html(obj.rss.channel.item[0].description);
    var $img = $div.find('img')
    $scope.imgSrc = $img.attr('src')
    

    http://jsfiddle.net/h6mp1o56/

    [Updated: Without jQuery]

    var div = angular.element('<div/>').html(obj.rss.channel.item[0].description);
    var img = div.find('img')
    $scope.imgSrc = img.attr('src')
    

    http://jsfiddle.net/h6mp1o56/1/

    链接地址: http://www.djcxy.com/p/31736.html

    上一篇: json字符串到javascript对象

    下一篇: 如何从JSON对象获取HTML元素,内容或参数