Cryptaline Cryptaline - 2 months ago 13
HTML Question

Console.log in to a div

I'm using simple rss feed parser example from this topic = Rss Parser Example.

$.get('http://stackoverflow.com/feeds/question/10943544', function (data) {
$(data).find("entry").each(function () { // or "item" or whatever suits your feed
var el = $(this);

console.log("------------------------");
console.log("title : " + el.find("title").text());
console.log("author : " + el.find("author").text());
console.log("description: " + el.find("description").text());
});
});





Its perfect, however I want to show each output log in a specific div, eg:

title log goes in to a
<div class="Rss-Title"></div>
and so on. So @ the end I should have smth like this:

<div id="Rss">

<div class="Rss-Title"></div>

<div class="Rss-Author"></div>

<div class="Rss-Description"></div>

</div>


My question - whats a proper way to do smth like that? Thank you.

Ish Ish
Answer

You should use .html() function

<div id="Rss">

<div class="Rss-Title"></div>

<div class="Rss-Author"></div>

<div class="Rss-Description"></div>

</div>

$.get('http://stackoverflow.com/feeds/question/10943544', function (data) {
 $(data).find("entry").each(function () { // or "item" or whatever suits your feed
    var el = $(this);

    $('#Rss-Title').html(el.find("title").text());
    $('#Rss-Author').html(el.find("author").text());
    $('#Rss-Description').html(el.find("description").text());
 });
});
Comments