Created
August 6, 2019 09:01
-
-
Save faruk09/dbeda3d8c2db0a8706717c1bcb7f3dd5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| //HTML Code | |
| <button id="topBtn"><i class="fas fa-arrow-up"></i></button> | |
| //CSS Code | |
| #topBtn{ | |
| position: fixed; | |
| bottom: 40px; | |
| right: 40px; | |
| font-size: 22px; | |
| width: 50px; | |
| height: 50px; | |
| background: #e74c3c; | |
| color: white; | |
| border: none; | |
| cursor: pointer; | |
| display: none; | |
| } | |
| //JS code | |
| $(document).ready(function(){ | |
| $(window).scroll(function(){ | |
| if($(this).scrollTop() > 40){ | |
| $('#topBtn').fadeIn(); | |
| } else{ | |
| $('#topBtn').fadeOut(); | |
| } | |
| }); | |
| $("#topBtn").click(function(){ | |
| $('html ,body').animate({scrollTop : 0},800); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment