Last active
December 7, 2017 02:35
-
-
Save trangsihung/5c87afd048bb9b73746b to your computer and use it in GitHub Desktop.
jQuery Scripts
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
//Check to see if the window is top if not then display button | |
$(window).scroll(function(){ | |
if ($(this).scrollTop() > 100) { | |
$('.scrollToTop').fadeIn(); | |
} else { | |
$('.scrollToTop').fadeOut(); | |
} | |
}); | |
//Click event to scroll to top | |
$('.scrollToTop').click(function(){ | |
$('html, body').animate({scrollTop : 0},800); | |
return false; | |
}); |
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
$('.top-nav a').on('click', function(e) { | |
e.preventDefault(); | |
target = $(this).attr('href'); | |
$('html, body').animate({ | |
scrollTop : $(target).offset().top | |
},800); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment