Aymanshafei (Talk | contribs) |
Aymanshafei (Talk | contribs) |
||
Line 1: | Line 1: | ||
<html> | <html> | ||
+ | <button id="myBtn" title="Go to top"><i class="fa fa-arrow-up fa-3x"></i></button> | ||
<footer style='bottom: 0px; | <footer style='bottom: 0px; | ||
position: fixed; | position: fixed; | ||
Line 26: | Line 27: | ||
<script> | <script> | ||
$(document).ready(function() { | $(document).ready(function() { | ||
+ | $('#myBtn').click(function(){ | ||
+ | document.body.scrollTop = 0; | ||
+ | document.documentElement.scrollTop = 0; | ||
+ | }) | ||
+ | window.onscroll = function () { scrollFunction() }; | ||
+ | function scrollFunction() { | ||
+ | if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { | ||
+ | document.getElementById("myBtn").style.display = "block"; | ||
+ | } else { | ||
+ | document.getElementById("myBtn").style.display = "none"; | ||
+ | } | ||
+ | } | ||
+ | |||
document.getElementById('navbar-toggle').onclick = function () { | document.getElementById('navbar-toggle').onclick = function () { | ||
var active = document.querySelector(".navbar-collapse"); | var active = document.querySelector(".navbar-collapse"); |
Latest revision as of 13:32, 27 October 2017