Search code examples
jqueryjquery-selectorsgetappendtumblr

jQuery .get > append div to page


I am trying to implement script which loads automatically all the content from tag in tumblr. Code looks like this:

if (is_int($("#page-count").text())) {totalPages = parseInt($("#page-count").text())};
for ( pageCount=2; pageCount<=totalPages;pageCount++) {
    $.get("/page/" + pageCount, function(data){$('#test').append($('data > #gallery')});

}

The problem is that I cannot select #gallery content using $('data > #gallery') (or at least, I am doing it completely wrong). Could somebody give me a hint on how to select it properly?


Solution

  • Ok, so I didn't manage to use any of your answers, instead I found out that, if I add HTML comments before and after the content I want to use, I can do it like this:

    for ( pageCount=2; pageCount<=totalPages;pageCount++) {
        $.get("page/" + pageCount, function(data){
            new_posts = data.split("<!-- posts-start --\>")[1].split("<!-- posts-end --\>")[0];
            $("#gallery").append(new_posts);
        });
    }