1

I'm setting up a webpage for a school competition and I want to write some code that when the mouse hovers over the footer, it will expand to full screen.

I have already written the code but one the JavaScript .getElementById() function cannot locate my footer with the id foot.

const footer = document.getElementById("foot");


footer.addEventListener("mouseenter", fullscreen);
footer.addEventListener("mouseleave", original);


function fullscreen() {
    footer.classList.add("fullscreen");
    footer.classList.remove("original");
}

function original() {
    footer.classList.add("original");
    footer.classList.remove("fullscreen");
}
@keyframes fullscreen {
    from {height: 10vh};
    to {height: 100vh};
}

@keyframes original {
    from {height: 100vh};
    to{height: 10vh};
}

.fullscreen {
    animation-name: fullscreen;
    animation-duration: 1500ms;
}

.original {
    animation-name: original;
    animation-duration: 1500ms;
}
<!DOCTYPE HTML>
<html>
  <head>
  </head>
  <body>
    <footer id="foot">
      <a href="#top"><h2>Let's Go</h2></a>
    </footer>
  </body>
</html>
Oram
  • 1,421
  • 2
  • 14
  • 20
The Pickle
  • 39
  • 1

0 Answers0