Sorry für doppelte Frage. Ich fand, dass es viele Fragen zu diesem Thema gibt, aber diese sind mir nicht hilfreich. Ich habe mehrere Kontrollkästchen.Nur eine Checkbox auswählbar von jeder Optionsgruppe
<div class="options">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
</div>
<div class="options">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
</div>
<div class="options">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
<input class="option" type="checkbox">
</div>
...
...
Ich möchte nur eine Checkbox kann von jeder Gruppe ausgewählt werden. Ich habe mit jQuery versucht, aber es funktioniert für jedes Kontrollkästchen nicht für einzelne Gruppe von Kontrollkästchen.
$('body').on('change','.option', function() {
$('.option').not(this).prop('checked', false);
});
versuchen andere mit diesem
$('body').on('change','.option', function() {
$(this).parent('.options').find('.option').prop('checked', false);
$(this).prop('checked', true);
});
Aber niemand meinen Zweck lösen. Bitte helfen Sie.
Warum nicht verwenden Sie Radio-Buttons? – antoni