If you don't say more, see the example
1, HTML structure
<div class= "Return_top" ></div>
2, CSS style
. return_top{
width:50px;
height:50px;
Background:url (.. /images/lanren.gif) no-repeat Center #FF8D16;
position:fixed;
right:30px;
bottom:30px;
Display:none;
Cursor:pointer;
z-index:99;
}
3, JS effect
<script>
$ (function () {
$ (window). Scroll (function () {
var topdistance=$ (window). scrolltop (); Gets the height of the mouse moving in the existing state of this window
if (topdistance>100) { //If the move height is greater than 100px, the top icon displays only, if the move height is less than or equal to 100, the top icon does not display
$ ('. Return_top '). FadeIn (a);
else{
$ ('. Return_top '). fadeout (a);
}
});
$ ('. Return_top '). On (' click ', Function () {
$ (' html,body '). Animate ({scrolltop:0},800);///Must be selected with $ (' html,body ') Otherwise no effect
})
;
</script>
The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring some help, but also hope that a lot of support cloud Habitat community!