If I had a div, and wanted it to automatically scroll when its scrollbar was at the bottom, how would I do so with the code I have here? It does not work correctly for me.
var scroll = false;
if ($("#console").scrollTop() == ($("#console").prop("scrollHeight") - 503)) {
scroll = true;
}
if (scroll == true) {
$("#console").prop({ scrollTop: $("#console").prop("scrollHeight") });
}
How would I do this if the div’s height was dynamic, instead of a static size?
hexacyanide,
You need to attach an event handler to the container. What you have here now the code will always be false since you are not capturing any event that is happening.