I have 4 checkboxes: one "All" and three different element. The different elements has a class, the "All" checkbox has an id. I want to make checked the "All" checkbox if not checked any other elements. I made this code but not working (Mind means All)
<label><input type="checkbox" id="check-nemek-mind" rel="nemek-mind" checked /><strong>Mind</strong></label>
</div>
<div class="checkbox">
<label><input type="checkbox" class="check-nemek" rel="nemek-noi"/>Női divat</label>
</div>
<div class="checkbox">
<label><input type="checkbox" class="check-nemek" rel="nemek-ferfi"/>Férfi divat</label>
</div>
<div class="checkbox">
<label><input type="checkbox" class="check-nemek" rel="nemek-gyerek"/>Gyerek divat</label>
</div>
<script>
$(document).ready(function(){
$('#check-nemek-mind').click(function() {
$('.check-nemek').prop('checked', false);
$('#check-nemek-mind').prop('checked', true);
});
$('.check-nemek').click(function() {
$('#check-nemek-mind').prop('checked', false);
if(document.getElementByClass('check-nemek').checked) {} else {$('#check-nemek-mind').prop('checked', true);}
});
});
</script>
Aucun commentaire:
Enregistrer un commentaire