How do I toggle two different images with Bootstrap? I want them to act as radio buttons, but I also want them to change images, indicating one is "active" and one isn't.
My page: http://matthewtbrown.com/test/imageasbutton/
code snippet
.btn .btn-primary .active .thisweek {
padding: 0px;
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
content:url(../images/thisweek.png);
}
.btn .btn-primary .thisweek {
padding: 0px;
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
content:url(../images/thisweek_inactive.png);
}
.btn .btn-primary .active .alltime {
padding: 0px;
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
content:url(../images/thisweek.png);
}
.btn .btn-primary .alltime {
padding: 0px;
border-left-width: 0px;
border-right-width: 0px;
border-top-width: 0px;
border-bottom-width: 0px;
content:url(../images/alltime_inactive.png);
}
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active thisweek">
<input type="radio" name="options" id="option1" autocomplete="off" checked> <img src="images/thisweek.png" width="108" height="27" style="float: left" alt=""/>
</label>
<label class="btn btn-primary alltime">
<input type="radio" name="options" id="option2" autocomplete="off"><img src="images/alltime_inactive.png" width="259" height="27" alt=""/>
</label>
</div>