[removed] Scroll to nth row in a table?

前端 未结 5 912
暖寄归人
暖寄归人 2020-12-30 05:21

Using either pure Javascript or jQuery, how do I scroll the page so that the nth row in a table is centered on the page?

Some examples I\'ve seen that have this sort

5条回答
  •  一向
    一向 (楼主)
    2020-12-30 06:05

    aka-g-petrioli

    I have corrected the followings from your answer.

     $('#control button').click(function(){
        var w = $(window);
        var row = table.find('tr')
            .removeClass('active')
            .eq( +$('#line').val() )
            .addClass('active');
    
        if (row.length){
            w.scrollTop( row.offset().top - row.offset().top/5);
        }
    });
    

    This will help you to scroll accurate position.

提交回复
热议问题