"Image Checkbox Buttons"
Bootstrap 3.0.3 Snippet by cristianogaspar

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <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'); }); });

Related: See More


Questions / Comments: