Skip to content

Instantly share code, notes, and snippets.

@guaiamum
Last active December 21, 2017 12:03
Show Gist options
  • Save guaiamum/1a12d42ec113b6e52f0f36c2f23825c6 to your computer and use it in GitHub Desktop.
Save guaiamum/1a12d42ec113b6e52f0f36c2f23825c6 to your computer and use it in GitHub Desktop.
radio button like behavior with btn-group
<style>
#radioBtn .notActive {
color: #555;
}
#radioBtn .active {
z-index: 0;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('#radioBtn a').on('click', function () {
var sel = $(this).data('title');
var tog = $(this).data('toggle');
$('#' + tog).prop('value', sel);
$('a[data-toggle="' + tog + '"]').not('[data-title="' + sel + '"]')
.removeClass('active').addClass('notActive');
$('a[data-toggle="' + tog + '"][data-title="' + sel + '"]').removeClass('notActive')
.addClass('active');
});
</script>
<div class="input-group">
<div id="radioBtn" class="btn-group">
<a class="btn btn-default active" data-toggle="passou" data-title="1">APROVADO</a>
<a class="btn btn-default notActive" data-toggle="passou" data-title="2">AMBOS</a>
<a class="btn btn-default notActive" data-toggle="passou" data-title="3">REPROVADO</a>
</div>
<input type="hidden" name="passou" id="passou" value="1">
</div>
<p class="text-muted"> Thanks to: https://bootsnipp.com/snippets/featured/radio-button-tabs </p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment