diff --git a/app.js b/app.js index d5591aea..8ac3263c 100644 --- a/app.js +++ b/app.js @@ -23,3 +23,23 @@ menu_item.forEach((item) => { mobile_menu.classList.toggle('active'); }); }); + +var mybutton = document.getElementById("back2Top"); + + +window.onscroll = function() {scrollFunction()}; + +function scrollFunction() { + if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) { + mybutton.style.display = "block"; + } else { + mybutton.style.display = "none"; + } +} + +// When the user clicks on the button, scroll to the top of the document +function topFunction() { + document.body.scrollTop = 0; + document.documentElement.scrollTop = 0; +} + diff --git a/index.html b/index.html index 6624159e..6fb92dd0 100644 --- a/index.html +++ b/index.html @@ -212,6 +212,8 @@
-