Technologies Ignited

Scrolling an element to its bottom using jQuery

Advertisements

Here’s a very nice example of scrolling a certain div to its bottom.
You might need such a thing, for example, if you are developing an ajax chat.
You must have the jQuery library loaded and in our case the div has id chatHolder.

	//Append the new content goes here
	//Getting the element's new height now
	var sHeight = $('#chatHolder')[0].scrollHeight;
	//Scrolling the element to the sHeight
	$('#chatHolder').scrollTop(sHeight);
Advertisements

Advertisements