Div with scroll bar - 使用scrollTop滚动到顶部()
问题描述:
如何滚动到顶部#studentName
?Div with scroll bar - 使用scrollTop滚动到顶部()
我用过css到#studentName
。所以滚动条出现在100px之后。所以我需要的是当goTop()被触发时能够去#studentName
的顶层。
CSS:
#studentName{
overflow-y: scroll;
max-height: 100px;
}
这是我已经试过。 (没有滚动)
function goTOP(){
$('#studentName').animate({ 'scrollTop': 0 }, 100);
}
答
只是删除引号,它应该工作。
function goTOP(){
$('#studentName').animate({ scrollTop: 0 }, 100);
}
答
您滚动为0px在100毫秒
$("#studentName").scrollTop(0)
此功能取决于你的jQuery版本....
上面的代码对我来说工作得很好。可能会在其他代码中的其他位置发布。 – Abhijeet 2014-10-29 16:04:18