2012-04-14 46 views
0

这是XML文件从一个RSS feed如何显示使用jQuery XML属性附加伤害(zRSSFeed脚本内)

<item> 
<title>creamy whites</title> 
<description>&lt;p&gt;&lt;a href="/pin/201606520789168653/"&gt;&lt;img 
src="http://media-cache.pinterest.com/upload/229261437250994034_0HxSxJNv_b.jpg" 
&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;creamy whites&lt;/p&gt;</description> 
</item> 

片断现在这是已经在ZRRSfeed代码:

// Add feed row 
html += '<li class="rssRow '+row+'">' + 
    '<'+ options.titletag +'><a href="'+ entry.link +'" title="'+   
     feeds.title +'" target="'+ options.linktarget +'">' 
     + entry.description +'</a></'+ 
     options.titletag +'>' 

现在不是得到entry.decription我想获得的src值是entry.decription 内我曾尝试: entry.decription[src]entry.decription[src].val()entry.decription->srcentry.decription.attr(src),entry.decription.getAtrribute("src")(我可能在这里误输入了这些代码 - 但是当我尝试它们时,我在Google中检查了诸如'getAttribute'之类的东西)并且它们都没有工作。

回答

0

尝试

$(entry.description).find('img').attr('src') 
+0

这是行不通的。输出是'未定义' - 没有错误出现。谢谢 – aurel 2012-04-14 23:57:27

1

试试这个..

var src = $('entry.description')find('img').attr('src'); 

console.log(src); // debug using console firebug in firefox 
//or developer tools in chrome 
//the output should be the url of img 

然后更换entry.description即位于锚标记内的SRC。

相关问题