Jump to content

Scrolling to the bottom of a field


gerkintrigg

Recommended Posts

Use $(obj).animate( { scrollTop: $(elementToScrollTo).offset().top } , 500, "swing", function(whenComplete){});.

Also check out the documentation at the jQuery site if you need to know more about it.

http://api.jquery.com/animate/

I've done this: 

function loadLog(){		
		var oldscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
		$.ajax({
			url: "log.html",
			cache: false,
			success: function(html){		
				$("#chatbox").html(html); //Insert chat log into the #chatbox div				
				var newscrollHeight = $("#chatbox").attr("scrollHeight") - 20;
				if(newscrollHeight > oldscrollHeight){
					$("#chatbox").animate({ scrollTop: newscrollHeight }, 'normal'); //Autoscroll to bottom of div
				}				
		  	},
		});
	}

It would appear that this SHOULD work... but it's not.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.