How to access the bottom of the block?

Good afternoon.

There is the following problem. Write your own chat. Created a block with the property overflow-y: scroll;.
Using PHP to fill up there are many messages.

Now I need to make when opening, open the bottom of the block, so I can see the last message, not the first. I.e. scrolling should be at the bottom.

Thank you for your attention.
March 20th 20 at 11:52
1 answer
March 20th 20 at 11:54
Solution
var block = document.getElementById("block");
 block.scrollTop = block.scrollHeight;
If I made the right?

the <script>
 var block = document.getElementById("scroll");
 block.scrollTo = block.scrollHeight;
</script>


The block which contains the ordered message id="Scroll"

But unfortunately that does not happen.
block.scrollTo = block.scrollHeight;
That line means that to scroll to a place that is equal to the height of this unit? If Yes, then I asked the height of the stationary unit. - jevon commented on March 20th 20 at 11:57
The issue was resolved!. THANK you! - jevon commented on March 20th 20 at 12:00

Find more questions by tags CSSHTML