How to maintain page scroll position after a jquery event is carried out?

前端 未结 7 1982
无人共我
无人共我 2020-12-04 23:47

I have searched high and low for an answer and have found similar examples of the problem but the answers do not apply to my scenario. The reality is I am new to this and th

相关标签:
7条回答
  • 2020-12-05 00:44

    I had a similar problem getting scrollTop to work after reload of div content. The content scrolled to top each time the procedure below was run. I found that a little delay before setting the new scrolltop solved the issue.

    This is cut from wdCalendar where I modified this procedure:

     function BuildDaysAndWeekView(startday, l, events, config)
       ....
            var scrollpos = $("#dvtec").scrollTop();
            gridcontainer.html(html.join(""));
            setTimeout(function() {
                $("#dvtec").scrollTop(scrollpos);
            }, 25);
       ....
    

    Without the delay, it simply did not work.

    0 讨论(0)
提交回复
热议问题