Home > Web Front-end > JS Tutorial > body text

Using Javascript to achieve smooth jump between anchors_javascript skills

WBOY
Release: 2016-05-16 18:46:59
Original
1086 people have browsed it

I believe many people are familiar with Anchor. It facilitates visitors to quickly jump to different locations on the page and directly find the content they are interested in. If RSS is a summary of the entire website, then the anchor is a summary of a page. , usually when a page contains a lot of content, anchor points will be used to position it.

But there is also a problem with anchor points. Usually, after clicking the anchor point, the page will jump to the target location immediately. However, the method introduced in this article achieves smooth jump between anchor points (Anchor), and the effect is very good.

Copy code The code is as follows:




Calling method:
Copy code The code is as follows:

scroller(el, duration)
el : target anchor ID
duration : duration, in milliseconds, the smaller the faster

HTML:
Copy code The code is as follows:




header_1 --> header_4





header_2 --> header_5





header_3 --> header_6





header_4 --> header_7





header_5 --> header_3





header_6 --> header_2





header_7 --> header_1




测试代码:
复制代码 代码如下:







用 Javascript 实现锚点(Anchor)间平滑跳转 - 平滑, 锚点, Anchor, 跳转, 滚动, javascript,














Use Javascript to implement anchor points (Anchor) smooth jump



                                                                                                                   . ********************************* Example code starts****************** *******************-->






    
    header_1 --> header_4
    





    
    header_2 --> header_5
    





    
    header_3 --> header_6
    





    
    header_4 --> header_7
    





    
    header_5 --> header_3
    





    
    header_6 --> header_2
    





    
    header_7 --> header_1
    







    


    











Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template