This article mainly introduces how to implement the floating back button in js. The example analyzes the style and dynamic implementation skills of javascript to implement the return top function, which is of great practical value, for more information about how to implement the floating back button in js, see the example in this article. Share it with you for your reference. The specific implementation method is as follows:
Float back to top buttonScript
Window. onscroll = function () {if (document. body. scrollTop | document.doc umentElement. scrollTop> 0) {document. getElementById ('rtop '). style. display = "block"} else {document. getElementById ('rtop '). style. display = "none "}}
Function toTop () {window. scrollTo ('0', '0'); document. getElementById ('rtop '). style. display = "none"} scriptBack to Top
Top testTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestTestBottom
I hope this article will help you design javascript programs.