skip to Main Content

I am using VS code to create a website, and I want to create a button that when clicked on, redirects to a different page on the website itself.
enter image description here

I want clicking the MENU button to lead to a new page. I have created a new file for the page I want to be redirected to, I am just unsure how to have MENU act as a button that will take me there. I am using JavaScript and HTML/CSS in VS code.

enter image description here
So I want the button to take me to MENU.js

I tried using HTML to create a button but that only seems to work when I am linking to a URL. I also tried the following.

MENU

but that doesn’t seem to work.

2

Answers


  1. Look into the Anchor Tag. This is a tag which allows you to link to other hyperlinks, telephone numbers, emails…

    Login or Signup to reply.
  2. Why shouldn’t you just use the link tag <a> instead of a button tag? Or onclick attribute for button:

    1. <a href="http://www.stackoverflow.com">Content</a>
    2. <button type="button" onclick="location.href='http://www.stackoverflow.com'">Content</button>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search