Welcome to %s forums

<No. 1 Community for developers, by developers/>

Login Register

How to check if checkbox is checked using jQuery?

Get support on JavaScript,jQuery, AJAX and other related technology.
Post Reply
admin
Site Admin
Posts: 45

How to check if checkbox is checked using jQuery?

Post by admin » Wed Oct 16, 2019 10:48 pm

Code: Select all

if($("#checkboxID").is(':checked'))
      // checked - Do some code for checked condition
else
     // unchecked -  Do some code for unchecked condition
or

Code: Select all

// traditional attr method
$('#checkboxID').attr('checked'); // "checked"
// new property method
$('#checkboxID').prop('checked'); // true
or using JS

Code: Select all

if(document.getElementById('checkboxID').checked) {
    // checked - Do some code for checked condition
} else {
  // unchecked -  Do some code for unchecked condition
}

Post Reply