Any idea why this code keeps saying on and doesn’t work how expected ?
$('#myCheckbox').click(function() {
if ( $('#myCheckbox').attr('checked')) {
alert("on");
} else {
alert("off");
}
});
example here
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
1) Use prop added to jQuery 1.6 (I guess)
2)Use is to check the state
Try this:
Working example: http://jsfiddle.net/BFf5H/2/
3) @Felix’s suggestion
Try this:
EDIT:
As per the URL provided by OP alternate solution: