I have got three div blocks with three checkboxes and I would like to change the div blocks background color when I click on each checkbox.
When I try this:
<style type="text/css">
.calendar-content {
float: left;
width: 100%;
min-height: 112px;
border: 1px solid #ccc;
position: relative;
display: block;
margin-top: -1px;
}
.checkbox input[type="checkbox"] {
margin-top: 1px;
width: 20px;
height: 20px;
margin-left: -24px;
padding-left: 24px;
}
.checkbox:checked ~ .calendar-content {
background: #CCC;
}
</style>
<div class="calendar-content checkbox">
<input type="checkbox" id="select_campaign" style="margin-left: 20px; margin-top: 28px; float: left;">
</div>
<div class="calendar-content checkbox">
<input type="checkbox" id="select_campaign" style="margin-left: 20px; margin-top: 28px; float: left;">
</div>
<div class="calendar-content checkbox">
<input type="checkbox" id="select_campaign" style="margin-left: 20px; margin-top: 28px; float: left;">
</div>
It will not change the color for each div block when I click on each checkbox. I dont know why it wont let me to change the div blocks color so I guess there is something wrong with my code.
Jsfiddle: http://jsfiddle.net/sx5p4j3k/
Can you please show me an example how I could use css to change the color for the div blocks when I click on each checkbox?
Thank you.