【发布时间】:2011-01-28 07:37:55
【问题描述】:
XML:
<item>
<title>Some title</title>
<description>
<![CDATA[
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
Some description text Some description text Some description text Some description text Some description text Some description text
]]>
</description>
<media:content isDefault="true" medium="image" url="http://sampledomain.com/image.jpg">
<media:title>Image title</media:title>
<media:description>Image description</media:description>
<media:thumbnail url="http://sampledomain.com/image.jpg" width="160" height="120" />
</media:content>
<wfw:commentRss>http://sampledomain.com/comment/feed/</wfw:commentRss>
<slash:comments>0</slash:comments>
</item>
我正在从 ajax 获取 css,在 onsuccess 函数中我的代码如下:
$(xml).find('item').each(function() {
var title = $(this).find('title').eq(0).text();
var url = $(this).find('content').attr('url');
// Printing url as undefined
alert(url);
console.log($(this).find('content');
});
我想要获取内容 url 属性我正在获取子项(标题、描述、内容、commentRss 和 cmets) 但是当我尝试获取 $(this).find('content') 它没有给我任何东西 谁能弄清楚我做错了什么? 谢谢
【问题讨论】:
-
var url=$(this).find('content').attr('url').val();或尝试使用 .text() 希望对您有所帮助