How do I scroll a row of a table into view (element.scrollintoView) using jQuery?

后端 未结 11 1637
刺人心
刺人心 2020-11-27 12:37

I\'m dynamically adding rows to a table using jQuery. The table is inside a div which has overflow:auto thus causing a vertical scroll

11条回答
  •  不知归路
    2020-11-27 13:06

    I found a case (overflow div > table > tr > td) in which scrolling to the relative position of the tr does not work. Instead, I had to scroll the overflow container (div) using scrollTop to .offset().top -

    .offset().top. Eg:

    $('#container').scrollTop( $('#tr').offset().top - $('#td').offset().top )
    

    提交回复
    热议问题