Skip to content

Commit

Permalink
javascript console errors #2025
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrug authored and jdonis committed Sep 23, 2024
1 parent 54baac4 commit e098462
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions _includes/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,22 @@
{% endif %}
<script>
// Explore challenges button scroll to active challenges section of react app
document.getElementById("js-explore-challenges").addEventListener("click", function(e) {
var scrollTarget = document.getElementById(e.target.getAttribute("data-anchor"))
scrollTarget.scrollIntoView()
})
document.addEventListener("DOMContentLoaded", function() {
var exploreChallengesElement = document.getElementById("js-explore-challenges");

if (exploreChallengesElement) {
exploreChallengesElement.addEventListener("click", function(e) {
var scrollTarget = document.getElementById(e.target.getAttribute("data-anchor"));
if (scrollTarget) {
scrollTarget.scrollIntoView();
} else {
console.error("Scroll target not found.");
}
});
} else {
console.error("Element with ID 'js-explore-challenges' not found.");
}
});

// Footer archived challenges link to scroll to top of page
document.getElementById("js-archived-challenges").addEventListener("click", function(e) {
Expand Down

0 comments on commit e098462

Please sign in to comment.