I am making a ajax chat using jquery, and I am trying to animate messages that are new.
- $("#submitmsg").click(function(){ var clientmsg = $("#usermsg").val(); $.post("post.php", {text: clientmsg}); $("#usermsg").attr("value", ""); return false; });
- function loadLog(){
- var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
- $.ajax({
- url: "log.php",
- cache: false,
- success: function(html){
- $("#chatbox").html(html);
- var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
- if(newscrollHeight > oldscrollHeight){
- $('#chatbox').animate({
- scrollTop: newscrollHeight
- }, {
- duration: 5000,
- complete: function() {
- $(".post:last").animate({opacity: .1}, 1000);
- }
- });
- }
- },
- });
- }
- setInterval (loadLog, 2000);
However, its just constantly animating the last item... I'm lost... :(