Skip to content

Commit

Permalink
Added auto scroll to top when clicked on pagination buttons (#1898)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nishakulkarni06 authored Dec 11, 2024
1 parent bf9db26 commit 59ba2b1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5995,9 +5995,9 @@ <h3>Provides the user's zodiac sign by taking the date of birth as input.</h3>

<!-- Pagination Section Starts Here -->
<div id="pagination-controls">
<button id="prev" onclick="changePage(-1)">Previous</button>
<button id="prev" onclick="changePage(-1); scrollToSearch()">Previous</button>
<span id="page-info"></span>
<button id="next" onclick="changePage(1)">Next</button>
<button id="next" onclick="changePage(1); scrollToSearch()">Next</button>
</div>

<!-- Pagination Section Ends Here -->
Expand Down
7 changes: 7 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,3 +343,10 @@ function validateName(inputId) {
input.value = value.replace(/[^A-Za-z ]/g, ''); // Remove any non-alphabetic characters
}
}

function scrollToSearch() {
const searchBar = document.getElementById('searchBar');
searchBar.scrollIntoView({
behavior: "smooth"
});
}

0 comments on commit 59ba2b1

Please sign in to comment.