Javascript: Remove checked status from disabled input on load (already checked)
On load, the script is not un-checking the disabled checkboxes, I have tried everything. I ha开发者_StackOverflow社区ve even tried running this code from Chrome Console, and it is working, but not in normal ways. Where is the error? (Note: I'm using prototype framework library) Javascript:
document.observe("dom:loaded", function() {
$(document.body).select('input').each(function(element) {
init();
element.observe('click', function(element) {
init();
});
});
loopGroup1();
loopGroup3();
loopGroup4();
});
function init() {
$(document.body).select('input').each(function(element) {
if (!element.checked) {
element.up().removeClassName('yes');
} else {
element.up().addClassName('yes');
}
if (element.disabled && element.checked) {
element.checked = !element.checked;
element.up().removeClassName('yes');
}
});
}
Try adding == true
to each operand in your if
statements. It's a minor thing that shouldn't affect anything, but it could. It's possible that in its current form it's simply checking to see whether the attribute exists, not what its value is.
精彩评论