문제

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');
}
도움이 되었습니까?

해결책

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

if ($('#SaveCheckbox').is(':checked')) {
     console.log('Checked');
} else {
     console.log('Unchecked');
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top