Cross browser JavaScript (not jQuery…) scroll to top animation

后端 未结 20 1063
抹茶落季
抹茶落季 2020-11-22 11:01

I\'m looking for a simple, cross-browser \"scroll to top\" animation I can apply to a link. I don\'t want to require a JS library such as jQuery/Moo, etc.

//         


        
20条回答
  •  一生所求
    2020-11-22 11:36

    I see that most/all of the above posts search for a button with javascript. This works, as long as you have only one button. I would recommend defining an "onclick" element inside the button. That "onclick" would then call the function causing it to scroll.

    If you do it like that, you can use more than one button, as long as the button looks something like this:

    
    

提交回复
热议问题