//Doesn't Work...
var chatBox = document.getElementById("chatBox");
function drawLoop(){
chatBox.scrollTop = chatBox.scrollHeight;
}
//Work...
function drawLoop(){
var chatBox = document.getElementById("chatBox");
chatBox.scrollTop = chatBox.scrollHeight;
}
在尝试将其设置在函数之外时,我做错了什么?
感谢。
解决方案:我在创建chatBox之前加载了脚本。