Skip to content

Commit

Permalink
scroll function
Browse files Browse the repository at this point in the history
  • Loading branch information
KajalDeore04 authored Jan 14, 2025
1 parent 36dc712 commit fddfbd4
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testimonial.html
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,28 @@ <h3>Subscribe to Our Newsletter</h3>
<button id="scrollBtn" title="Go to top">
<i class="fa-solid fa-arrow-up fa-lg"></i>
</button>
<script>
// Get the button element
const scrollBtn = document.getElementById('scrollBtn');

// Show the button when the user scrolls down 100px from the top
window.onscroll = function () {
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
scrollBtn.style.display = "block";
} else {
scrollBtn.style.display = "none";
}
};

// Scroll to the top of the page when the button is clicked
scrollBtn.onclick = function () {
window.scrollTo({
top: 0,
behavior: "smooth"
});
};

</script>


<!-- Floating Image Button -->
Expand Down

0 comments on commit fddfbd4

Please sign in to comment.