Back to Top

HTML
<div class="container"> <div class="row"> <div id="toTop"> ↑ </div> </div> </div>
CSS
.container{ min-height:600px; } #toTop { position: fixed; bottom: 50px; right: 30px; width: 50px; background-color: #02d871; cursor: pointer; border-radius: 50px; height: 50px; font-size: 20px; color: #fff; display: none; text-align: center; line-height: 48px; z-index: 99; border:1px solid #fff; }
Javascript
$(function() { $(window).scroll(function() { if($(this).scrollTop() != 0) { $('#toTop').fadeIn(); } else { $('#toTop').fadeOut(); } }); $('#toTop').click(function() { $('body,html').animate({scrollTop:0},800); }); });