"radio to glyphicons"
Bootstrap 3.3.0 Snippet by inge1980

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <div class="container"> <div class="row"> <div class="btn-toolbar" role="toolbar" aria-label="basic toolbar"> <div class="btn-group" role="group" aria-label="basic label"> <p class="text-center">Set radio buttons:</p> </div> <div class="btn-group" data-toggle="buttons"> <label class="btn btn-default btn-xs"> <input type="radio" name="options" id="option1" value="1" /> <span class="glyphicon glyphicon-ok"></span> </label> <label class="btn btn-danger btn-xs active"> <input type="radio" name="options" id="option2" value="0" /> <span class="glyphicon glyphicon-remove"></span> </label> </div> </div> </div> </div> It works <a href="http://jsfiddle.net/7euuax5v/show/">here</a>, but if you use any of the "Preview"/"HTML"/"CSS"/"JS" at the top here at Bootsnipp, you will not see it working afterwards.
$('input[id=option1]').on("change",function () { alert('test1'); $(this).parent().toggleClass('btn-default').toggleClass('btn-success'); $('[id=option2]').parent().toggleClass('btn-default').toggleClass('btn-danger'); }); $('input[id=option2]').on("change",function () { alert('test2'); $(this).parent().toggleClass('btn-default').toggleClass('btn-danger'); $('[id=option1]').parent().toggleClass('btn-default').toggleClass('btn-success'); });

Related: See More


Questions / Comments: