Created
June 30, 2015 15:11
-
-
Save lorashfuko/9b3a5fe58cc9a066af89 to your computer and use it in GitHub Desktop.
Авто-скрол по клику наверх (jQuery)
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
jQuery(document).ready(function(){ | |
jQuery("#scroll-up").hide(); | |
jQuery(function () { | |
jQuery(window).scroll(function () { | |
if (jQuery(this).scrollTop() > 1000) { | |
jQuery('#scroll-up').fadeIn(); | |
} else { | |
jQuery('#scroll-up').fadeOut(); | |
} | |
}); | |
jQuery('a#scroll-up').click(function () { | |
jQuery('body,html').animate({ | |
scrollTop: 0 | |
}, 800); | |
return false; | |
}); | |
}); | |
}); | |
/********************************************************************************************* | |
HTML | |
<a title="Вверх" href="#masthead" id="scroll-up" style="display: none; text-decoration: line-through !important;" rel="nofollow">Наверх</a> | |
CSS | |
a#scroll-up { | |
bottom: 20px; | |
position: fixed; | |
right: 40px; | |
width: 60px; | |
height: 60px; | |
display: none; | |
opacity: 0.5; | |
filter: alpha(opacity=50); | |
padding: 10px 16px; | |
border-radius: 2px; | |
} | |
*********************************************************************************************/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment