javascript - How to get the dom element at the top of the current page in js.
黄舟2017-05-19 10:29:38
0
2
662
Mainly I want to achieve an effect similar to the right navigation bar of Baidu Encyclopedia. As the page scrolls, the navigation bar on the right also changes. Thanks.
Listen to the
window.onscroll
event. When scrolling, dynamically determine the current scrolling distance. The code is roughly as follows:I don’t know if this is a similar effect you want? A small demo written by myself