TypeError:$(...)[0]未定义

时间:2013-11-22 09:56:52

标签: jquery typeerror

在我的聊天脚本中,以下行发生错误:

$("#chatbox_"+chatboxtitle+" .chatboxcontent")
.scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
setTimeout('$("#chatbox_"+chatboxtitle+" .chatboxcontent")
.scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);', 100);

1 个答案:

答案 0 :(得分:0)

试试这个

setTimeout(function () {
    $("#chatbox_"+chatboxtitle+" .chatboxcontent")
    .scrollTop($("#chatbox_"+chatboxtitle+" .chatboxcontent")[0].scrollHeight);
}, 100);