I'm having a problem with a set of radio buttons.
<div class="btn-group control-buttons" data-toggle="buttons-radio">
<button type="button" class="btn">One</button>
<button type="button" class="btn">Two</button>
<button type="button" class="btn">Three</button>
</div>
See here: http://jsfiddle.net/dhbenson/LM9uW/
When the buttons are clicked, they don't ever stay depressed (i.e. none ever appear to be "active").
Does anyone know why not? What else do I need to do to make these buttons work properly?
EDIT
Ah, I see. I forgot to include the bootstrap js code.
This fiddle works: http://jsfiddle.net/dhbenson/qNeSS/
To set the active state for Bootstrap Buttons, use the . active class.
Active/Disabled Buttons The class . active makes a button appear pressed, and the disabled attribute makes a button unclickable. Note that <a> elements do not support the disabled attribute and must therefore use the . disabled class to make it visually appear disabled.
You need the bootstrap javascript for that functionality.
Add this to your HTML head:
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
Try this code:
<div class="btn-group" data-toggle="buttons-checkbox">
<button type="button" class="btn">Left</button>
<button type="button" class="btn">Middle</button>
<button type="button" class="btn">Right</button>
</div>
and add one file i.e. bootstrap-button.js
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