$(window).on("load scroll", function () { var top = $(document).scrolltop(), wheight = $(window).height(); if (top > wheight) { $(".side6").fadein("fast"); $(".wyz-top").fadein("fast"); $(".wyz").css({ "height": 50 }); } else { $(".side6").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); }); $(function () { $('#scrolltotop').click(function () { $('html , body').animate({ scrolltop: 0 }, 'slow'); }); });