$(window).on("load scroll", function () { var top = $(document).scrollTop(), wHeight = $(window).height(); if (top > wHeight) { $(".sideBar").fadeIn("fast"); $(".wyz-top").fadeIn("fast"); $(".wyz").css({ "height": 50 }); } else { $(".sideBar").hide(); $(".wyz-top").hide(); $(".wyz").removeAttr("style"); } }); $(".side6").on("click", function () { $("html,body").stop().animate({ scrollTop: 0 }, 500); }); $(".wyz-top").on("click", function () { $("html,body").stop().animate({ scrollTop: 0 }, 500); });