$(window).on("load scroll", function () { var top = $(document).scrolltop(), wheight = 0; if (top > wheight) { $(".sidebar").fadein("fast"); $(".wyz-top").fadein("fast"); $(".wyz").css({ "height": 50 }); } else { $(".sidebar").hide(); $(".wyz-top").hide(); $(".wyz").removeattr("style"); } }); $(".sidet").on("click", function () { $("html,body").stop().animate({ scrolltop: 0 }, 500); }); $(".wyz-top").on("click", function () { $("html,body").stop().animate({ scrolltop: 0 }, 500); });