Q:

if checkbox checked jquery value 1

//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
if ($('#check_id').is(":checked"))
{
  // it is checked
}
9
$(your_checkbox).is(':checked');
3
// Check a checkbox
$(selector).prop('checked', true);
// Un-check a checkbox
$(selector).prop('checked', false);
// Determine if checked or not
isChecked = $(selector).prop('checked');
2
console.log($('input[name="locationthemes"]:checked').serialize());

//or

$('input[name="locationthemes"]:checked').each(function() {
   console.log(this.value);
});
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
var checked = '0';  if($('#checkbox').prop('checked')){ checked = '1'; }
0
$('#' + id).is(":checked")
4

New to Communities?

Join the community