Buttons vs code editor

Viewed 20

I have recently downloaded vs code editor to replace atom which I have been using and the only editor I have ever used I am new to coding so please bear with me. So I copied the code written in atom from one of my projects and pasted it to vs code and installed live server to open the code onto a web page on my computer but when I was using atom I have a button on my page and when clicked took me to another page of my web site. When I open the main page using live server on vs code it opens the main page but when I click the button to open another page of my site nothing happens. I have clicked to open the second page from my vs code account using the live server and it opens no problem just wondering how to get it to open when the button is clicked on the we page? Any idea’s

1 Answers

If it is a HTML button element, you should provide onClick event and then use some javascript to navigate to another location. Something like:

<button type="button" onclick="window.location.href='/link-to-your-page'">Button name</button>

If it is an anchor tag, then you should provide 'href' attribute. Paste your code to get more insight ;)

Related