자바스크립트/🟡 Jquery
스크롤을 이용한 top버튼
비니_
2021. 5. 17. 11:02
728x90

<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title> Top버튼 스크롤하기~ </title>
</head>
<body>
<button type="button" name="button" id="topBtn"></button>
또는
<a id="topbtn"></a>
</body>
</html>
$(function(){
//탑버튼
$("#topBtn").click(function(){
$("html, body").animate({
scrollTop: 0
}, 500);
});
});
728x90