Click here to Skip to main content
15,894,460 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How can I link url in my button? So if a person clicks on the button it goes to another website.
For example,

<nav class="main-menu">
                <ul>
                    <li><a href="#home">Home</a></li>
                    <li><a href="#event">Event</a></li>
                    <li><a href="#members">Member</a></li>
                  
		<li><a href="#more">More</a></li>
			<
                    <li><a href="#contact">Contact</a></li>
                </ul>
            </nav>


What I have tried:

And how I can link the url over here and could you please tell me where do I have to put the codes?
Posted
Updated 3-Feb-17 3:17am

You haven't shown the code for button.
However you can do this by just using the HTML anchor tag, something like following-
HTML
<a href="http://www.w3schools.com">Visit W3Schools.com!</a>

Reference: HTML a tag[^]
If you want have button like appearance then you can try -
Without javascript:
HTML
<form action="http://www.w3schools.com">
    <input type="submit" value="This is a button link">
</form>

With javascript:
HTML
<input type="button" value="This is button link" onclick="window.location.href='http://www.w3schools.com'">


Hope, it helps :)
 
Share this answer
 
Comments
Karthik_Mahalingam 5-Feb-17 4:36am    
5
Suvendu Shekhar Giri 6-Feb-17 1:40am    
Thanks :)
Check this out: HTML a href Attribute[^]
If you really want a button to act like a link, read this How do I create an HTML button that acts like a link?[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900