I have a bootstrap checkbox the problem is I can't get the value of it when it is checked. The code below is my check box.
<div class="col-md-auto">
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" id="briskbusiness" value="1">
Brisk Business
<i class="input-frame"></i>
</label>
</div>
</div>
</div>
Here is my Jquery:
$(document).on('change','#briskbusiness',function() {
if(this.checked){
alert();
}
});
I tried using click and change and still it won't show alert.
Here is the look of my check box.

Your code seems to be working fine. may me issue with importing jQuery library
<script
src="https://code.jquery.com/jquery-3.5.1.min.js"
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0="
crossorigin="anonymous"></script>
<div class="col-md-auto">
<div class="form-group">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input" id="briskbusiness" value="1">
Brisk Business
<i class="input-frame"></i>
</label>
</div>
</div>
</div>
<script>
$(document).on('change','#briskbusiness',function() {
a = $("input[type='checkbox']").val();
if(this.checked){
alert(a);
}
});
</script>
check above code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With