I am working on a comments system, using PHP + jQuery. I need to add the last comment to the top, before all the div elements. E.G.
<div id="comment">
<div class="comment-3"></div>
<div class="comment-2"></div>
<div class="comment-1"></div>
</div>
So now I want to add the new <div class="comment-4"></div> with jQuery to look like that:
<div id="comment">
<div class="comment-4"></div>
<div class="comment-3"></div>
<div class="comment-2"></div>
<div class="comment-1"></div>
</div>
Edit:
NOTE: I am using:
$.ajax({
type: "POST", url: "ajax.php", cache : false, data: goData, dateType: "text",
success: function(data){
$("#comment").append(data);
$("#submit").attr({ disabled:false, value:"Shout it!" });
}
});
Or more realistic
Of course you can use the
prependTosyntax to if that is more natural for youFor more such tricks check the jQuery documentation
jQuery 1.3 Manipulation API