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
  • 60,441
  • 24
  • 124
  • 159
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
  • 195,511
  • 20
  • 184
  • 225
-1

You can try setting the <a> inside the <button> like this

<button>
<a href="http://www.facebook.com/">Salir</a>
</button>
Carlos Vallejo
  • 2,006
  • 1
  • 7
  • 13