jquery bootstrap checkbox val
To get the value of a checkbox using jQuery and Bootstrap, you can use the is(':checked')
function. Here's an example:
<div class="form-check">
<input class="form-check-input" type="checkbox" id="exampleCheckbox">
<label class="form-check-label" for="exampleCheckbox">
Example Checkbox
</label>
</div>
var isChecked = $('#exampleCheckbox').is(':checked');
console.log(isChecked); // true or false
This code selects the checkbox element with the ID "exampleCheckbox" and checks if it is checked using the is(':checked')
function. It will return true
if the checkbox is checked and false
if it is not checked.