The navbar won't resize on scroll, can anyone point out what I'm doing wrong? Thank you :)

The navbar won't resize on scroll, can anyone point out what I'm doing wrong? Thank you :)
0

#1

https://codepen.io/noethix/pen/GYBaqK


#2

There’s no getElementByTagName, only getElementsByTagName.


#3

I have tried it also and it doesn’t work either…


#4

It’s because now you’re getting a list of elements that have the nav tag. Grab the first one only :wink:

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";
  }
}

#5

Thank you :slight_smile: