0

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?

aflac
  • 1

3 Answers3

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