Created
August 30, 2016 10:59
-
-
Save koentjuh1/a33e55c008d03833aeec04bc75a67a4b to your computer and use it in GitHub Desktop.
Scroll to div
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Scroll button: */ | |
<div class="arrow-icon scroll" data-rel="#arrow-scroll-to"> | |
</div> | |
/* Scroll to: */ | |
<div id="arrow-scroll-to"> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(".scroll").on('click', function() { | |
var target = $(this).data('rel'); | |
var $target = $(target); | |
$('html, body').stop().animate({ | |
'scrollTop': $target.offset().top | |
}, 900, 'swing'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment