Question:
How can I make a button that sends me to another page that I specify? So far I have only known how to do it with the <a>
tag and its href and target attributes. But I can't do it with a <button>
.
Answer:
You can do it like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
</style>
</head>
<body>
<button onclick="location.href='https://www.facebook.com'">Llévame a otro lado</button>
</body>
</html>
You do not occupy any of the a label, but thanks to location.href it indicates the address to which you want to go