Skip to content

Instantly share code, notes, and snippets.

@rodan888
Created August 7, 2015 06:58
Show Gist options
  • Save rodan888/bc30f43006a00649e078 to your computer and use it in GitHub Desktop.
Save rodan888/bc30f43006a00649e078 to your computer and use it in GitHub Desktop.
function scrollBut(){
$('<button type="button" class="up">&#9650;</button>').appendTo('body');
var up = $('.up');
up.css({
position: 'fixed',
border: 'none',
bottom: '20px',
left: '0',
display: 'none',
width: '50px',
height: '50px',
lineHeight: '45px',
textAlign: 'center',
fontSize: '30px',
borderRadius: '50%',
"-webkit-borderRadius": '50%',
color: '#fff',
backgroundColor: '#C75C5C',
outline: 'none',
padding: '0',
zIndex: '10'
});
$(window).scroll(function(){
if ($('body').scrollTop() > 600) {
up.fadeIn('slow');
}else{
up.fadeOut('slow');
};
});
up.click(function() {
$('body').animate({scrollTop:0}, 1000);
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment