My HTML code has a <ul>
element with the following structure:
<ul id="messages">
</ul>
In my HTML file, I have not specified any <li>
items. However, in my JavaScript code using jQuery, I dynamically add <li>
items to the <ul>
element.
$("#messages").append("<li>" + string + "</li>");
The issue I am facing is that when the list gets too long to fit on the screen, the newly added <li>
items are not automatically scrolled into view. How can I make sure that the list scrolls down to show the latest items?