본문 바로가기

js

[js]top btn 탑버튼 반응형 디플논


let btn = $(".top_btn");

$(window).scroll(function(){
    let st = $(window).scrollTop();
    let w = $(window).width();
    
    if(st>200 && w>1024){
        btn.show();
    }else{        
        btn.hide();
    }
})

btn.click(function(){
	$("html, body").animate({
    	scrollTop: 0
	},500)
})

top