Suffii Suffii - 2 months ago 5
jQuery Question

Issue on Reseting (Deselecting) Bootstrap Radio Buttons

Can you please take a look at this demo and let me know why I am not able to Deselect all Radio Buttons by using following code:

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

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


This should work. Your selector is wrong and also you aren't closing your on method.

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

Also if you really want to know the active isn't being applied to the input radio it's being applied to the parent so if you really want to select just radios then you would have to select the radios and then the parent like so:



Here is an example that alerts the value

Updated version: