I've created a filter controlled with checkboxes and using jQuery I've 1) removed the original checkboxes ... $('.toggle_bdrms input:checkbox').css('display', 'none'); ..and used CSS to give the checkbox labels the look of square buttons.
Now I'd like to toggle the checkbox styling using jQuery to fill in the boxes with background-color: white. I've succeeded in using jQuery to get the label background to change, but the toggle() function isn't doing what I want, namely toggle the background color from none to white and back when the label is clicked.
Thanks in advance for any guidance/assistance.
https://jsfiddle.net/baskinco/e7utzowb/3/
$('.toggle_bdrms input').toggle(function() {
$('.toggle_bdrms input:checkbox').css('display', 'none');
$('.toggle_bdrms label').css({'background-color':'#FFFFFF', 'color':'#00a9b7'});
});
.toggle_bdrms > * {
float: left;
}
.toggle_bdrms input[type=checkbox]{
display: none;
}
.toggle_bdrms label{
display: block;
text-align: center;
letter-spacing: .15em;
border: 1px solid $white;
background-color: none;
width: 170px;
padding: 5px 8px;
margin: 5px 0;
color: $white;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="row">
<form name="filter" method="post" action="" id="slidefilter">
<div class="toggle_bdrms">
<input id="onebdrm" type="checkbox" value="onebdrm">
<input id="twobdrm" type="checkbox" value="twobdrm">
<label for="onebdrm">ONE BEDROOM</label>
<label for="twobdrm">TWO BEDROOM</label>
</div>
</form>
</div>