Javascript: Remove checked status from disabled input (already checked)
Im trying to make this function to check an element and if its checked, or not, add or remove respective className. Also, if the element is disabled but i开发者_运维知识库s checked, it should un-check it and remove the className('yes')
function init() {
$(document.body).select('input').each(function(element) {
if (!element.checked) {
element.up().removeClassName('yes');
} else {
element.up().addClassName('yes');
}
if (element.checked && element.disabled) {
element.checked = false;
element.up().removeClassName('yes')
}
});
}
Right now, the last part, is not working, no effect
Did you try element.checked = !element.checked
in the last part instead of element.checked = false
?
精彩评论