mardi 27 janvier 2015

jQuery check if one checkbox is checked and another unchecked

I got this HTML:



<input type="checkbox" id="checkw" "checked" />Woman<br>
<input type="checkbox" id="checkm" />Männer<br>


I want to find out if checkw is checked and checkm is unchecked so I tried different ways like:



if($('#checkw').prop('checked') || $('#checkm').prop('unchecked'))
{
alert("w");
}


and



if($('#checkw').is(':checked') || $('#checkm').is(':unchecked'))
{
alert("w");
}


and



if($('#checkw').is(':checked',true) || $('#checkm').is(':checked',false))
{
alert("w");
}


But I always get the alert when checkm is also checked. Any ideas?





Aucun commentaire:

Enregistrer un commentaire