开发者

how to add var's to a .append string

开发者 https://www.devze.com 2023-01-24 01:57 出处:网络
I am parsing some xml <item> <title>New Story Test</title> <description>Story 1</description>

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(' / ')
}));
0

精彩评论

暂无评论...
验证码 换一张
取 消