Home >Web Front-end >JS Tutorial >After clicking TOP, it does not jump directly to the top of the page, but scrolls up_javascript skills
If the web page is too long, anchor tags are generally used to quickly return to the TOP
top It is indeed very simple, but there are some masters Make this simple:
Overseas demo address: http://tonyyoo.com/v2/
After clicking TOP, it does not jump directly to the top of the page, but scrolls Up. . And the longer it is from the top of the page, the faster it will scroll. . .
After some research, there are 4 JS used:
Looks like It's all so complicated. . I don’t know if there is any simpler code that can achieve the same effect. I can’t do it. .
After the page is onloaded, traverse all hyperlinks and determine whether there is a #header in the href. If so, just trigger scrollTo. . .