Javascript: Remove checked status from disabled input (already checked)

Posted by BoDiE2003 on Stack Overflow See other posts from Stack Overflow or by BoDiE2003
Published on 2010-05-14T21:10:41Z Indexed on 2010/05/14 21:14 UTC
Read the original article Hit count: 206

Filed under:
|
|

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 is 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

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html