jQuery.get("ajax.php", function(data)
{
prev = $("#newsfeed").html(); //Remember what was in the newsfeed
$(data).find("div[id^='feed']").each(function() //Find every div starting with feed in AJAX response
{
alert('#' + $(this).attr("id")); //Works fine
$('#' + $(this).attr("id")).remove(); //Remove any existing div with same id - Not working
});
$("#newsfeed").html(data + prev); //Append the AJAX response to the top of the page
});
Please help, I’m relativly new to Jquery and don’t have a clue what’s going wrong.
I’ll do one better. It looks like you are removing data and then adding it back later.
If you just prepend to html, the new data will go on the top.
Best of luck!