There’s no getElementByTagName
, only getElementsByTagName
.
I have tried it also and it doesn’t work either…
It’s because now you’re getting a list of elements that have the nav
tag. Grab the first one only
function scrollFunction() {
if (document.body.scrollTop > 80 || document.documentElement.scrollTop > 80) {
document.getElementsByTagName("nav")[0].style.padding = "15px 0px";
} else {
document.getElementsByTagName("nav")[0].style.padding = "30px 0px";
}
}
1 Like
Thank you