TOP 버튼 초간단 소스 코드 입니다.
<!-- 상단으로 이동하기 버튼 -->
<a href="#" class="btn_gotop">
<span>TOP</span>
</a>
<style>
.btn_gotop {
display:none;
position:fixed;
bottom:30px;
right:30px;
z-index:999;
border:1px solid #000080;
outline:none;
background-color:white;
color:#000080;
cursor:pointer;
padding:15px 20px;
border-radius:100%;
}
</style>
<script>
$(window).scroll(function(){
if ($(this).scrollTop() > 300){
$('.btn_gotop').show();
} else{
$('.btn_gotop').hide();
}
});
$('.btn_gotop').click(function(){
$('html, body').animate({scrollTop:0},400);
return false;
});
</script>
- 다음 사이트에서 퍼왔지만 처음 출처인지는 모르겠습니다.
- 출처: https://url.kr/bbs/board.php?bo_table=coding_tips&wr_id=143