0

Can you please take a look at this Bootstrap 3 Radio button example and let me know why I am not able to set default selected radio for second option?

<div class="btn-group" data-toggle="buttons">
  <label class="btn btn-default active">
    <input type="radio" name="options" id="option1" autocomplete="off"> opt 1 
  </label>
  <label class="btn btn-default">
    <input type="radio" name="options" id="option2" autocomplete="off" checked="checked"> opt 2
  </label>
  <label class="btn btn-default">
    <input type="radio" name="options" id="option3" autocomplete="off"> opt 3
  </label>
</div>

as you can see I have already set the second option as:

 <input type="radio" name="options" id="option2" autocomplete="off" checked="checked"> opt 2

but the checked="checked" is not doing the job! Can you please also let me know how I can get selected radio value by jquery ?

Thanks?

Behseini
  • 6,066
  • 23
  • 78
  • 125

1 Answers1

0

To style the second option as the default just add the active class to the label (and remove it from the first one).

To learn how to get the selected value using jQuery look at this answered question.

Community
  • 1
  • 1
omma2289
  • 54,161
  • 8
  • 64
  • 68