dB'
dB'

Reputation: 8330

How to get bootstrap buttons to show active state?

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/

Upvotes: 6

Views: 13579

Answers (2)

Amir T
Amir T

Reputation: 2758

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>

Upvotes: 3

Rupesh Nerkar
Rupesh Nerkar

Reputation: 391

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

Upvotes: 1

Related Questions