For the above checkbox
document.getElementById("checkbox1").checked // -> returns true
But
var byAppr = document.getElementById('checkbox1').value;
$(byAppr).attr('checked') // -> returns undefined
I am testing this in firefox 3.6
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.
Use one of the following:
$('#checkbox1').prop('checked')– in jQuery 1.6+, usually the way to go$('#checkbox1').is(':checked')– all jQuery versions, but slower$('#checkbox1').attr('checked')– NOT in jQuery 1.6 – but in 1.6.1 and <=1.5, don’t use itAlso, in cases where you already have the DOM element available directly (e.g.
thisin an event handler bound to the field), usethis.checkedinstead of$(this)with one of the methods above!