lundi 29 février 2016

Check if all checkbox are checked not working

i try to check if all checkbox are checked and change the class of an button. But my code are not working and i don't know why.

  <input type="checkbox" id="check1" onchange="checkIfChecked();" class="checkThis" value="check 1"> Check 1<br />
<input type="checkbox" id="check2" onchange="checkIfChecked();" class="checkThis" value="check 2"> Check 2<br />
<input type="checkbox" id="check3" onchange="checkIfChecked();" class="checkThis" value="check 3"> Check 3<br />
<input type="checkbox" id="check4" onchange="checkIfChecked();" class="checkThis" value="check 4"> Check 4<br />
<input type="checkbox" id="check5" onchange="checkIfChecked();" class="checkThis" value="check 5"> Check 5<br /><br />
<a href="#" style="width:190px;display:block;" id="absenden" class="button-theme-disable">
    <span class="span_outer">
        <span class="span_right">
            <span class="span_left">
                <span style="width: 182px;" class="span_inner">Speichern & Schließen</span>
            </span>
        </span>
    </span>
</a>
    function checkIfChecked() {

    if ($('.checkThis input[type="checkbox"]').not(':checked').length == 0) {
        $('#absenden').removeClass('button-theme-disable');
        $('#absenden').addClass('button-theme');
    } else {
        $('#absenden').removeClass('button-theme');
        $('#absenden').addClass('button-theme-disable');
    }

};

Here are a demo: http://ift.tt/1Qg4KLF

What i'm doing wrong? Thanks for reading!




Aucun commentaire:

Enregistrer un commentaire