From b393e504535e2e4f9d05f1ca228092e32a04eec9 Mon Sep 17 00:00:00 2001 From: Roshu2003 <123867126+Roshu2003@users.noreply.github.com> Date: Wed, 27 Sep 2023 13:37:13 +0530 Subject: [PATCH] Update index.js --- index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/index.js b/index.js index 0819302..04e2d9e 100644 --- a/index.js +++ b/index.js @@ -161,3 +161,19 @@ jQuery(document).ready(function($) { }); /* Chatboat Code */ }) + +// -------arrow scroll----------- +// ===== Scroll to Top ==== +$(window).scroll(function() { + if ($(this).scrollTop() >= 50) { // If page is scrolled more than 50px + $('#return-to-top').fadeIn(200); // Fade in the arrow + } else { + $('#return-to-top').fadeOut(200); // Else fade out the arrow + } +}); +$('#return-to-top').click(function() { // When arrow is clicked + $('body,html').animate({ + scrollTop : 0 // Scroll to top of body + }, 500); +}); +