Bootstrap 3 Button Groups - how to make them links?

This seems dumb to me, but what's the point of Bootstrap 3 button groups if you can't make them links?

http://getbootstrap.com/components/#btn-groups

We tried this:

<button type="button" class="btn btn-lg btn-success" href="add.php"> <span class="glyphicon glyphicon-plus"></span> Add </button> 

BUT...

 <button type="button" class="btn btn-lg btn-success"> <a href="add.php"><span class="glyphicon glyphicon-plus"></span> Add</a> </button> 

But they do not work as links. What I don’t understand here? Thanks. Nj

+7
twitter-bootstrap twitter-bootstrap-3
source share
3 answers

You can use classes in bootstrap to change the a tag.

 <div class="btn-group" role="group" aria-label="..."> <a href="" class="btn btn-default">Left</a> <a href="" class="btn btn-default">Middle</a> <a href="" class="btn btn-default">Right</a> </div> <a href="add.php" class="btn btn-lg btn-success"> <span class="glyphicon glyphicon-plus"></span> Add </a 

See an example here - http://www.bootply.com/v8anIQZU97

+18
source share

HTML buttons do not have an href attribute. Instead, try using anchor labels. Here's Plnkr , which illustrates a group of buttons using anchor tags to open search engines in a new window.

 <div class="btn-group"> <a class="btn btn-lg btn-success" href="http://www.google.com" target="_blank">Google</a> .... </div> 
0
source share

Try it...

  <button type="button" class="btn btn-lg btn-success" onclick="location.href='@Url.Action("Action", "Controller")'"> <span class="glyphicon glyphicon-plus"></span> Add </button> 
-one
source share

All Articles