//获取到下标为i的DOM元素
let commentItemDiv = $('#commentItemDiv').find('.mark').eq(i);
//获取i元素到页面顶部距离
let commentItemDivTop = $(commentItemDiv).offset().top;
//获取第一个元素到页面顶部距离
let firstCommentItemDivTop = $($('#commentItemDiv').find('.mark').eq(0)).offset().top;
//定位这个元素(定位`'#commentItemDiv'`中滚动条的位置)
//scrollTop为进度条位置
$('#commentItemDiv').animate({
scrollTop: commentItemDivTop-firstCommentItemDivTop
}, 500);
上面情景为在页面中的列表,有滚动条,然后要定位他的位置