virt2/api/templates/virtual-nt.ru/js/back_to_top.js

15 lines
469 B
JavaScript
Raw Normal View History

$(document).ready(function(){
$('body').append('<div id="toTop" class="btn btn-info"><span class="glyphicon glyphicon-chevron-up"></span><i class="fa fa-arrow-up"></i></div>');
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
$('#toTop').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
});
});