我有这个脚本可以按我的意愿工作,但我想知道如何将两个单击功能组合成一个以使其成为更好的脚本。
我的 jsfiddle 链接:jsfiddle.net/squirc77/BFZju/
谢谢你!
只需向两个“无线电输入”添加一个类,这样当单击其中一个时,脚本就会运行。
$('.myClass').click(function() {
if ($('#ind').is(':checked')) {
$('#ind_text').removeClass('grey');
$('#chk_ind').removeAttr('disabled');
} else {
$('#ind_text').addClass('grey');
$('#chk_ind').attr('disabled', 'disabled');
}
});
点击这里进行演示