2
var entry = result.feed.entries[i];
var div = document.createElement("div");

somewhere in the output of

div.appendChild(document.createTextNode(entry.content));

there are several

<img src="http://ww... is there a simple way just to get image url? Maybe something with .match?

4

1 回答 1

2

这是我做的方式..

var findImg = entry.content;
var img = $(findImg).find('img').eq(0).attr('src'); //i use jquery to find 1st img src

function imgFeed(){
    var defaultImg= "images/default.jpg"; 
    if(img==null){
        return defaultImg;  // if cant find any, show default image src
    }else{
        return img;
    }
}
yourElement.append('<img width="194" height="91" src="'+imgFeed()+'" alt="#" />');
于 2012-07-07T04:50:18.320 回答