scrolling to li element - jquery

前端 未结 4 975
逝去的感伤
逝去的感伤 2020-12-14 03:47

i have a \"ul\" that contains lots of \"li\" (several hundred), the ul has a fixed hight of about 400px and the css property overflow:scroll, each li has the height of 40px

4条回答
  •  醉话见心
    2020-12-14 04:18

    You can do like this:

    $('html, body').animate({
         scrollTop:$('#ulID li:eq(1)').offset().top
    }, 1000);
    

    You need to adjust value to eq for specific li or you can even customize the selector.

提交回复
热议问题