how to add var's to a .append string
I am parsing some xml
<item>
<title>New Story Test</title>
<description>Story 1</description>
<link>http://www.dirtybirddesignlab.com/tour</link>
<pubDate>Tue, 9 Nov 2010 09:32:16 GMT</pubDate>
</item>
and need the output to be as such
<link><title></link> | <description>
but no luck with th开发者_如何学Pythone following, its only displaying the "link" and there is no href applied
$(xml).find('item').each(function() {
var title = $(this).find('title').text();
var page = $(this).find('link').text();
var desc = $(this).find('description').text();
$('#ticker').append($('<li>', {text: page}, {text: title}, {text: desc}));
});
$('#ticker').newsTicker();
$('#ticker').append($('<li>', {
text: page + title + desc
}));
should do it. To separate them you might want to call:
$('#ticker').append($('<li>', {
text: [page, title, desc].join(' / ')
}));
精彩评论