$(window).scroll(function() { if ($(this).scrollTop() >= 100) { $(".sticky").addClass('paddingTop100'); // If page is scrolled more than 50px $(".scrollCart").fadeIn(); $(".scrollToTop").fadeIn(); $(".navMenu").addClass('fixed'); // Fade in the arrow } else { $(".sticky").removeClass('paddingTop100'); $(".scrollCart").fadeOut(); $(".scrollToTop").fadeOut(); $(".navMenu").removeClass('fixed'); // Else fade out the arrow } }); $(window).scroll(function() { if ($(this).scrollTop() >= 350) { $(".sticky").addClass('paddingTop100'); } else { $(".sticky").removeClass('paddingTop100'); } }); $(document).on("click",".add",function() { if ($(this).prev().val() <= 100) { $(this).prev().val(+$(this).prev().val() + 1); } }); $(document).on("click",".sub",function() { if ($(this).next().val() > 1) { if ($(this).next().val() > 1) $(this).next().val(+$(this).next().val() - 1); } }); $(function() { document.getElementById("year").innerHTML = new Date().getFullYear(); }); $(document).on("click",".scrollToTop",function() { $("html").animate({ scrollTop: 0, // Scroll to top of body }, 500 ); });