Bootstrap Unselect Startup Button

I would like to select only one option below that works fine, but also deselect using bootstrap that didn't select anything. Is there any way to do this?

<div class="btn-group" data-toggle="buttons-radio"> <button data-toggle="button" class="btn btn-small">1</button> <button data-toggle="button" class="btn btn-small">2</button> <button data-toggle="button" class="btn btn-small">3</button> </div> 
+8
radio-button twitter-bootstrap
source share
2 answers

You will need to do this using Javascript:

 $(".btn-group button").removeClass("active"); 

See here: http://jsfiddle.net/TrPFf/2/

+3
source share

If you use the Bootstrap Button plugin, you can wrap the switches in the "button" shortcuts as follows:

 <div class="btn-group" data-toggle="buttons"> <label class="btn btn-primary"> <input type="radio" name="options" id="option1"> Option 1 </label> <label class="btn btn-primary"> <input type="radio" name="options" id="option2"> Option 2 </label> <label class="btn btn-primary"> <input type="radio" name="options" id="option3"> Option 3 </label> </div> 

This makes for more semantic HTML and is easier for the user to type.

0
source share

All Articles