I do not want to use <a>
element to convert a button into a hyperlink.
I have the following buttons:
<button class="btn btn-success"> First button</button>
<button class="btn btn-success"> Second button</button>
How do I specify a hyperlink (without using <a>
) and browse to a page when I click on the buttons
You can use JavaScript for your solution. window.location.href
sets the URL for the button.
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<button class="btn btn-success" onclick="window.location.href='http://cdnjs.com/libraries/twitter-bootstrap'">First button</button>
can we know why you want the button to be button not link tag? would you consider this code helpful to achieve what you want ?
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<a href="http://www.google.com" role="button" class="btn btn-success btn-large">Google Now</a>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With