Technologies:
Tolerim
6 hours ago
What is the method for scrolling <ul><li></li></ul> to the bottom when a button is clicked?
io.on("new_message",function(data){
console.log(data);
var html ="";
if(data.sender==sender)
{
html+= "<li class='liRight'>"+data.msg+"</li> ";
}
else{
html+= "<li class='lileft'>"+data.msg+"</li> ";
}
messagelist.innerHTML+=html;
Scrollltobottom ();
})
function Scrollltobottom ()
{
console .log("scroll fiucvtiopjhn");
messagelist.scrollTop = messagelist.scrollHeight;
}
To clarify, I require assistance in ensuring that the list auto scrolls to the bottom upon button click. Please let me know if you require any additional information.Answers(1)
Tolerim
6 hours ago
Verified Answer
It looks like the code you provided is missing some context, such as what io and messagelist variables refer to. However, assuming that messagelist is a