效果图
一、代码
btn_letters(e, index) {
//点击省份首字母
// this.address=e.target.innerHTML
var LetterList_Dom = document.getElementsByClassName("city-item");
var LetterList_Dom_height = [];
for (var a = 0; a < LetterList_Dom.length; a++) {
LetterList_Dom_height.push({ height: LetterList_Dom[a].offsetHeight });
}
var scrollTop = 0;
for (var b = 0; b < index; b++) {
scrollTop += LetterList_Dom_height[b].height;
}
if (index >= 1) {
scrollTop = scrollTop;
}
var scrollYTop = document.getElementsByClassName("scroll-y");
scrollYTop[0].scrollTop = scrollTop;
},
总结
提示:做个纪录。