Using the Bootstrap btn-group to select a single value, how can I display the selected value? Here is an example of my code:
<div class="input-group">
<div id="radioBtn" class="btn-group">
<a class="btn btn-primary btn-sm active" data-toggle="fun" data-title="Y">YES</a>
<a class="btn btn-primary btn-sm notActive" data-toggle="fun" data-title="X">I don't know</a>
<a class="btn btn-primary btn-sm notActive" data-toggle="fun" data-title="N">NO</a>
</div>
<input type="hidden" name="fun" id="fun">
</div>
And here is the corresponding JavaScript:
$('#radioBtn a').on('click', function(){
var selected = $(this).data('title');
var toggle = $(this).data('toggle');
$('#'+toggle).prop('value', selected);
$('a[data-toggle="'+toggle+'"]').not('[data-title="'+selected+'"]').removeClass('active').addClass('notActive');
$('a[data-toggle="'+toggle+'"][data-title="'+selected+'"]').removeClass('notActive').addClass('active');
})