如何选择一个选项为true并将所有其他选项设置为false,而不管选择哪个用户选择真实选项?
注意:用户无法选择两个选项true。
$(function() {
$('select[name="verdadeira[]"]').change(function() {
$('select[name="verdadeira[]"]').each(function() {
if($(this).val() == 'V'){
$(this).val('V');
}
});
});
});
<select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" >
<option value="F" selected="selected"> Falsa</option>
<option value="V">Verdadeira</option>
</select>
<select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" >
<option value="F" selected="selected"> Falsa</option>
<option value="V">Verdadeira</option>
</select>
<select class="form-control v" name="verdadeira[]" style="width: 120px; height: 37px; float: left;" >
<option value="F" selected="selected"> Falsa</option>
<option value="V">Verdadeira</option>
</select>