"Image Checkbox Buttons"
Bootstrap 3.0.3 Snippet by denoise

<br /> <div class="container"> <div class="row"> <div class="col-md-6 col-md-offset-3"> <form class="form-horizontal well" role="form"> <div class="row"> <div class="col-xs-4"> <img src="http://placehold.it/160x100" class="img-responsive img-radio"> <button type="button" class="btn btn-primary btn-radio">Left</button> <input type="checkbox" id="left-item" class="hidden"> </div> <div class="col-xs-4"> <img src="http://placehold.it/160x100" class="img-responsive img-radio"> <button type="button" class="btn btn-primary btn-radio">Middle</button> <input type="checkbox" id="middle-item" class="hidden"> </div> <div class="col-xs-4"> <img src="http://placehold.it/160x100" class="img-responsive img-radio"> <button type="button" class="btn btn-primary btn-radio">Right</button> <input type="checkbox" id="right-item" class="hidden"> </div> </div> <div class="row space-20"> <div class="col-xs-12"> <div class="form-group"> <label for="inputTitle" class="col-sm-2 control-label">Title</label> <div class="col-sm-10"> <input type="text" class="form-control" id="inputTitle"> </div> </div> </div> </div> </form> </div> </div> </div>
.btn-radio { width: 100%; } .img-radio { opacity: 0.5; margin-bottom: 5px; } .space-20 { margin-top: 20px; }
$(function () { $('.btn-radio').click(function(e) { $('.btn-radio').not(this).removeClass('active') .siblings('input').prop('checked',false) .siblings('.img-radio').css('opacity','0.5'); $(this).addClass('active') .siblings('input').prop('checked',true) .siblings('.img-radio').css('opacity','1'); }); });

Similar snippets: See More


Comments:

comments powered by Disqus