I am having a problem when I try to set the scrollTop value for a text field. My JavaScript code is as follows:
var element = document.getElementById("messageTextArea"); console.log("scrollTop = "+element.scrollTop); console.log("scrollHeight = "+element.scrollHeight); element.scrollTop = element.scrollHeight;
The Firefox console log gives the following:
scrollTop = 0 scrollHeight = 86 The value is-->0 Now scrollTop = 0 Now scrollHeight = 86
What I really want to do is make sure that textarea automatically scrolls to the maximum when the text does not match the actual width and height, and the scroll bar is activated.
Here are two screenshots explaining the problem -
This is what I have at the moment -

And this is what I would like to have -

Please, help!
source share