I have a script that I'm trying to modify, but it's not working as expected. Can someone assist me with this issue?
window.onscroll = function() {myFunction()};
var navigation = document.getElementById("navigation");
var sticky = navigation.offsetTop;
function myFunction() {
if (window.pageYOffset > sticky) {
navigation.classList.add("sticky");
} else {
navigation.classList.remove("sticky");
}
}
Currently, the script adds the class "sticky" to the navigation element. However, I would like to add the class "padding-page" to the "page-content" element within this function and remove it afterwards. This is necessary because the sticky navigation changes the layout, causing the "page-content" section to shift an additional 48px towards the top.