~~~
<style>
div.one{
height: 12000px;
background: gold;
}
.fix{
width: 30px;
height: 50px;
background: red;
position: fixed;
z-index: 100;
bottom: 100px;
right: 50px;
}
</style>
~~~
~~~
<div class="one"> </div>
<div class="fix"> </div>
<script>
$(window).scroll(function(){
var scroll = $ (window).scrollTop();
console.log(scroll);
if(scroll>70){
$(".fix").fadeIn(300)
}
else{
$(".fix").fadeOut(300)
}
})
$(".fix").click(function(){
$("html,body").animate({scrollTop:0},300)
})
</script>
~~~