Created
August 7, 2015 06:58
-
-
Save rodan888/bc30f43006a00649e078 to your computer and use it in GitHub Desktop.
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
function scrollBut(){ | |
$('<button type="button" class="up">▲</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