<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>

<div class="goTop">
  回到頂部
</div>

<script>
  $(".goTop").click( function(){
      $("html,body").scrollTop( 0 );
  });
</script>
body {height:1000px;}

.goTop { position:fixed; top:50%; right:0; width:70px; height:70px; text-align:center; color:#fff; line-height:70px; background:rgba(0,0,0,0.8); cursor: pointer; transition: .5s;}

.goTop:hover { background:rgba(0,0,0,0.5); }

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.