I have been curious about the <button>
attribute. I can't seem to get it to work like <a>
attributes. What do I mean by that? Well, I can do <a href="url">Link</a>
to redirect you. But you can't do that with <button>
. How can I make a button do the same?
Asked
Active
Viewed 51 times
0

aflac
- 1
-
`` – Đinh Carabus Mar 12 '20 at 17:40
-
1Does this answer your question? [How to create an HTML button that acts like a link?](https://stackoverflow.com/questions/2906582/how-to-create-an-html-button-that-acts-like-a-link) – Naveen Mar 12 '20 at 17:42
-
You can look at this link https://stackoverflow.com/q/2906582/1047998 – Naveen Mar 12 '20 at 17:43
3 Answers
0
Do you mean like this?
<button onclick="location.href='http://www.google.com/';">Go There!</button>

scunliffe
- 62,582
- 25
- 126
- 161
0
Well you can attach a button to a form and have it submit it which will load the page.
<form id="xxx" action="https://www.stackoverflow.com"></form>
<button form="xxx">Go now!</button>

epascarello
- 204,599
- 20
- 195
- 236
-1
You can try setting the <a>
inside the <button>
like this
<button>
<a href="http://www.facebook.com/">Salir</a>
</button>

Carlos Vallejo
- 3,290
- 3
- 9
- 13