Javascript 同时使用scrollTop()两次

Javascript 同时使用scrollTop()两次,javascript,jquery,Javascript,Jquery,如何使用动画({scrollTop()})同时滚动多个div 例如,如果我运行下面的goTOP(){;函数,我想滚动到页面顶部,同时滚动到#studentName表的顶部 <table class="table table-striped table-hover" id="studentName"> <thead> <tr> <th class="col-md-2">ID</th> <th c

如何使用
动画({scrollTop()})
同时滚动多个div

例如,如果我运行下面的
goTOP(){;
函数,我想滚动到页面顶部,同时滚动到
#studentName
表的顶部

 <table class="table table-striped table-hover" id="studentName">
  <thead>
    <tr>
      <th class="col-md-2">ID</th>
      <th class="col-md-2">Subject</th>
    </tr>
  </thead>
  <tbody></tbody>
</table>
jQuery:这是我到目前为止一直在尝试的。没有按预期工作

function goTOP(){
  $('html, body').animate({ 'scrollTop' : 0 }, 700);//go top of page
  $('html, body').animate({ 'scrollTop' : $('#studentName').first().offset().top }, 100); // go to top level of this DIV
}

没有滚动到表的顶部吗?这是
$('#studentName')。动画({'scrollTop':0},100);
不滚动。div的ID是什么?谢谢。表ID是
studentName
用ID
studentList
包装在div中。我想滚动到表的顶部。用ID\studentList试试。可滚动的是div,对吗?我在上面的示例代码中做了更改。所有记录(文本)在
中。滚动条滚动
项。有人能帮忙吗?没有一个答案是完整的。表
#studentName
没有滚动到顶部。正如你所看到的,我使用了
溢出-y:scroll;
。所以我需要在
转到
#studentName
的顶层
函数被调用。有人能帮忙吗?
function goTOP(){
  $('html, body').animate({ 'scrollTop' : 0 }, 700);//go top of page
  $('html, body').animate({ 'scrollTop' : $('#studentName').first().offset().top }, 100); // go to top level of this DIV
}
function goTOP(){
  $('html, body').animate({ 'scrollTop' : 0 }, 700);//go top of page
  $('#studentName tbody').animate({ 'scrollTop': 0 }, 100); // go to top level of this DIV
}