我认为这很简单,但我无法弄清楚为什么#type2
不能点击。
<input type="radio" id="type1" name="group1" checked>
<input type="radio" id="type2" name="group1">
<input type="text" class="type1">
<input type="text" class="type2" disabled>
<script>
function toggle() {
if ($('#type1').attr('checked', true)) {
$('.type1').attr('disabled', false);
$('.type2').attr('disabled', true);
}
else if ($('#type2').attr('checked', true)) {
$('.type1').attr('disabled', true);
$('.type2').attr('disabled', false);
}
}
$(document).ready(function() {
toggle();
});
</script>
我看不出有什么问题。任何帮助都会很棒,谢谢。