I have implemented custom checkboxes using a custom CSS checkbox generator.
$( ".button" ).click(function() {
if(document.getElementById('terms_checkbox').checked) {
alert('Checkbox is checked');
} else {
alert('Checkbox is not checked');
}
});
.button{
background:red;
width:200px
height:100px;
}
.control {
font-family: arial;
display: block;
position: relative;
padding-left: 30px;
margin-bottom: 15px;
padding-top: 3px;
cursor: pointer;
font-size: 16px;
}
.control input {
position: absolute;
z-index: -1;
opacity: 0;
}
(control script and css code here)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="control-group">
<label class="control control-checkbox">
First checkbox
<input type="checkbox" />
<div class="control_indicator"></div>
</label>
</div>
<div class="button">
Click Me
</div>
After clicking the button, it fails to detect whether the checkbox is checked or not. What could be causing this issue?