Q:

jquery see if checkbox is checked

//using plane javascript 
if(document.getElementById('on_or_off_checkbox').checked) {
    //I am checked
} 

//using jQuery
if($('#on_or_off_checkbox').is(':checked')){
    //I am checked
}
21
$( "SELECTOR" ).attr( "checked" )  // Returns ‘true’ if present on the element, returns undefined if not present
$( "SELECTOR" ).prop( "checked" ) // Returns true if checked, false if unchecked.
$( "SELECTOR" ).is( ":checked" ) // Returns true if checked, false if unchecked.
9
$('#' + id).is(":checked")
4
if ($('#grepperRocks').is(':checked')) {
	// this checkbox is checked
}
3
if($('#on_or_off_checkbox').is(':checked')){
    //I am checked
}
1
$('#isAgeSelected').click(function() {
    $("#txtAge").toggle(this.checked);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js">
  </script>
<input type="checkbox" id="isAgeSelected"/>
<div id="txtAge" style="display:none">Age is something</div>
2
$('input.checkbox').is(':checked')
0

New to Communities?

Join the community