parallax scrolling jquery codepen code example
Example: simple parallax button scrolling jquery codepen
/* jQuery codes for smooth scrolling. The following code is from https://css-tricks.com/snippets/jquery/smooth-scrolling/*/$(function() { $('a[href*=#]:not([href=#])').click(function() { if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) { var target = $(this.hash); target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ scrollTop: target.offset().top }, 700); return false; } } });});/* Back to top scroll button. The following code is from http://jsfiddle.net/gilbitron/Lt2wH/*/if ($('#back-to-top').length) { var scrollTrigger = 100, // px backToTop = function() { var scrollTop = $(window).scrollTop(); if (scrollTop > scrollTrigger) { $('#back-to-top').addClass('show'); } else { $('#back-to-top').removeClass('show'); } }; backToTop(); $(window).on('scroll', function() { backToTop(); }); $('#back-to-top').on('click', function(e) { e.preventDefault(); $('html,body').animate({ scrollTop: 0 }, 700); });}