어쩌다 알게 된 ƪ(•̃͡•̃͡ ƪ

스크롤을 이용한 top버튼 본문

자바스크립트/🟡 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

'자바스크립트 > 🟡 Jquery' 카테고리의 다른 글

click과 on click 의 차이점??  (4) 2021.10.08
( jquery ) 개념 정리 1  (3) 2021.06.13
Comments