简体   繁体   中英

onclick=“location.href='manaliPackages.html'” not working

I want to link my button with another page. I am using the code given below to do so.

<button type="button" value="button text" class="commonBtn" 
onclick="location.href='manaliPackages.html'";> View Variations</button>

But it is not working... Why not?

Your code should work just fine
(I'm assuming manaliPackages.html is a file in the same directory as the html file holding your code.)
For example:
link/to/your/html/file.html contains the following:

<button type="button" value="button text" class="commonBtn" 
onclick="location.href='manaliPackages.html'";> View Variations</button>

Clicking this button would open: link/to/your/html/manaliPackages.html
Also, it is considered bad practice to use inline code, you should consider adding an event listener instead.
Please provide a snapshot of your browser console

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM