"Image Checkbox Buttons"
Bootstrap 3.0.3 Snippet by denoise

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<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>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
11
.btn-radio {
width: 100%;
}
.img-radio {
opacity: 0.5;
margin-bottom: 5px;
}
.space-20 {
margin-top: 20px;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
1
2
3
4
5
6
7
8
9
10
$(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');
});
});
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Related: See More


Questions / Comments:

Can you make another code for Bootstrap v3.3.5 please? ASAP

James Baque () - 9 years ago - Reply 0


Please help me to be multiselect

Samuel Fuentes Reyes () - 9 years ago - Reply 0


Awesome snipp. I forked it and made it work for multi-select. Full credit to you. Just tweaked it for my purposes.

Rich Brooks () - 9 years ago - Reply 0


Man, really thanks for this, just to help other peolple, if you can't not make it work try to add jquery to the page, like this: <script type="text/javascript" src="http://cdnjs.cloudflare.com..."></script> before the script code, so you can make it work well.

Mr.Gear () - 10 years ago - Reply 0


This is more like Radio buttons as multiple selections can't be made.

JTUI () - 10 years ago - Reply 0


thanks

Mahdi Pishguy () - 11 years ago - Reply 0