Open helloMihyun opened 5 years ago
function scroll_top(){ this.init = function(){ this.scrollBtn = ".topScroll", this.speed = 400; this.initEvent(); }; this.initEvent = function(){ var objThis = this; $(window).scroll(function(){ var sc = $(window).scrollTop(); if(sc >= 100){ $(objThis.scrollBtn).stop().fadeIn(); }else{ $(objThis.scrollBtn).stop().fadeOut(); } }); $(this.scrollBtn).on("click", function(){ console.log('o'); $(window).scrollTop(0); // $("body").stop().animate({ // windowTop : 0 // },objThis.speed); }); }; this.init(); }
function scroll_top(){ this.init = function(){ this.scrollBtn = ".topScroll", this.speed = 400; this.initEvent(); }; this.initEvent = function(){ var objThis = this; $(window).scroll(function(){ var sc = $(window).scrollTop(); if(sc >= 100){ $(objThis.scrollBtn).stop().fadeIn(); }else{ $(objThis.scrollBtn).stop().fadeOut(); } }); $(this.scrollBtn).on("click", function(){ console.log('o'); $(window).scrollTop(0); // $("body").stop().animate({ // windowTop : 0 // },objThis.speed); }); }; this.init(); }