Why is the side nav not working?

Why is the sidenav not working?


You need to redirect users to a different page. Adding or removing elements in a single page is just a hassle (which i assume you wanted to do initially).

  1. Create a folder with a index.html (i let you decide the name and what you want to put in it).

  2. Change your changePage(index) function to this and add an array called pages:

// array for redirects. change "PATH/TO/NEW_PAGE/" to the page you want to redirect.
const pages = ["/", "PATH/TO/NEW_PAGE"];

function changePage(index) {
  // creates an anchor element (used to redirect to other webpages).
  const link = document.createElement('a');
  link.href = pages[index];

  // simulates a click on the link.

Once you click on your link, it should redirect to your new page.