@sylvester Используйте animate() или scrollTop() метод в jQuery чтобы по клику скролить наверх страницы, посмотрите ниже пример кнопки наверх:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
<html> <head> <meta charset="utf-8"/> <script src="https://code.jquery.com/jquery-2.2.4.js"></script> <style> .wrapper { height: 3000px; } #gotop { position: fixed; bottom: 20px; right: 30px; z-index: 99; background-color: #000; color: #fff; cursor: pointer; padding: 15px; border-radius: 15px; font-size: 18px; } </style> </head> <body> <div class="wrapper"></div> <button id="gotop" title="Go to top">Наверх</button> </body> <script> $("#gotop").on("click", function () { // Плавный переход $('body').animate({scrollTop: 0}); // Или через scrollTop // $('body').scrollTop(0) return false; }) </script> </html> |