I have a page where users can post questions. Whenever a new question is posted I am cloning the div , updating it with new values and then prepending the div on top of of all the previous divs.This is my code:
var lastDiv = $("#divAll div:last").clone();
$("[id$='_imgPostAll']",lastDiv).attr("ImageUrl",post.d.sImageURL);
$("[id$='_lblNameAll']",lastDiv).html(post.d.sNickName);
$("[id$='_lblTimeAll']",lastDiv).html(post.d.sDate);
$("[id$='_lblShareAll']",lastDiv).html(post.d.sShareComment);
$("#divAll").prepend(lastDiv);
$("#divAll div:last").show("slow");`
The updated div is not showing up on the page. But when I replace var lastDiv = $("#divAll div:last").clone() with var lastDiv = $("#divAll").clone(), the updated div appears but it appears twice, thrice depending on the previous divs. I only want it to clone the last div and update it with new values rather than all the previous divs.
Your help will be really appreciated.