Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Radio Button Unselect

I would like to select only one option below which works fine, but also to deselect an option with bootstrap making nothing selected. Is there a 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>
like image 684
Mike Flynn Avatar asked Jan 18 '13 00:01

Mike Flynn


People also ask

How do I uncheck a radio button in CSS?

The :checked CSS pseudo-class selector represents any radio ( <input type="radio"> ) element that is checked. The idea is to use the :checked selector to identify the selected radio button and unset it.

How do you deselect a radio button react?

To uncheck radio buttons in React, we can set the checked prop of the radio button to false . We have the checked state that we use to set the checked prop of each radio button.

How do you check if a Radiobutton is checked?

To find the selected radio button, you follow these steps: Select all radio buttons by using a DOM method such as querySelectorAll() method. Get the checked property of the radio button. If the checked property is true , the radio button is checked; otherwise, it is unchecked.


1 Answers

You'd have to do that with Javascript:

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

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

like image 141
Manuel Ebert Avatar answered Sep 22 '22 17:09

Manuel Ebert