我想檢查複選框,如果它的值== 1和未檢查,如果價值== 0.請建議一些邏輯。預先感謝誰幫助我。複選框值檢查,如果它的值等於1
<div class="checkbox">
<label><input type="checkbox" class="preference" value="1" data-value="size1" id="datasize1">A</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="0" data-value="size2" id="datasize2">B</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="1" data-value="size3" id="datasize3">C</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="1" data-value="size4" id="datasize4">D</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="0" data-value="size5" id="datasize5">E</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="1" data-value="size6" id="datasize6">F</label>\
</div>\
<div class="checkbox">\
<label><input type="checkbox" class="preference" value="0" data-value="size7" id="datasize7">G</label>\
</div>
$('.preference').each(function(e){
if($(this).val() == 1){
$(this).checked;
}
});
先生,我想在加載時檢查複選框值。我不希望這個更改或點擊 –