Question

Intending to check weather the checkbox is checked or not . In both the cases , if the checkbox is checked or unchecked , i am getting the message checked . Is it the right way to handle this checking or there is some other way.

if ($('#SaveCheckbox').attr('checked') != true)
{
 console.log('Checked');
}
 else
{
  console.log('Unchecked');
}
Was it helpful?

Solution

please check this code ,use :checked attribute and is condition

if ($('#SaveCheckbox').is(':checked')) {
     console.log('Checked');
} else {
     console.log('Unchecked');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top