how can i disable and enable a sub radio button on click to the another radio button using jquery.
I want to disable radio button(er_que) when i click radio button(#atten) and enable the same when i click radio button(#quest)
<tr>
<td>What do you want to know?<br />
<input name="er_1" id="atten" type="radio" value="attendence" /> Attendance<br />
<input name="er_1" id="quest" type="radio" value="que_ask" /> Questions Asked<br />
</td>
</tr>
<tr>
<td><input name="er_que" type="radio" value="total" /> Total Number<br />
<input name="er_que" type="radio" value="issue_wise" /> Issues Wise
</td>
$('input[name="er_1"]').change(function() {
if ($(this).val() == 'attendence') {
$('input[name="er_que"]').attr('disabled', 'disabled');
return;
}
$('input[name="er_que"]').removeAttr('disabled');
}
});
Something like this:
$('document').ready(function() {
$('input[name="er_1"]').change(function() {
if ($(this).val() == 'attendence') {
$('input[name="er_que"]').removeAttr('disabled');
} else {
$('input[name="er_que"]').attr('disabled', 'disabled');
}
});
});
Working demo:
The following should do the trick:
// Disable //
$('#atten').click(function(){
$('input[name="eq_que"]').attr('disabled','disabled');
});
// Enable //
$('#quest').click(function(){
$('input[name="eq_que"]').removeAttr("disabled");
});
I hope it helps!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.