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
Look into the Anchor Tag. This is a tag which allows you to link to other hyperlinks, telephone numbers, emails…
Why shouldn’t you just use the link tag
<a>
instead of a button tag? Oronclick
attribute forbutton
:<a href="http://www.stackoverflow.com">Content</a>
<button type="button" onclick="location.href='http://www.stackoverflow.com'">Content</button>