Last active
August 21, 2022 23:59
-
-
Save akramulhasan/775b48fc5ce3b4145090dc4ffc9f4622 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
jQuery(document).ready(function($){ | |
var offset = 700; | |
var speed = 250; | |
var duration = 500; | |
$(window).scroll(function(){ | |
if ($(this).scrollTop() < offset) { | |
$('.topbutton') .fadeOut(duration); | |
} else { | |
$('.topbutton') .fadeIn(duration); | |
} | |
}); | |
$('.topbutton').on('click', function(){ | |
$('html, body').animate({scrollTop:0}, speed); | |
return false; | |
}); | |
}); | |
//Text to be placed for icon makrup (FontAwesome Required) | |
<a href="#" class="topbutton"><i class="fa fa-chevron-circle-up"></i></a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script (along with some other code in functions.php) will add Scroll to top feature in a WordPress site