<div id="crm-radio-is_recur_radio-wrapper" class="crm-radio-wrapper crm-radio-wrapper-200px selected"><input class="" value="" type="radio" id="CRM_QFID_is_recur_radio" name="is_recur_radio"><label for="CRM_QFID_is_recur_radio">One-Time</label></div>
<input class="payment_processor_easy-pay crm-form-radio" value="4" type="radio" id="CRM_QFID_4_payment_processor_id" name="payment_processor_id">
<div id="crm-radio-is_recur_radio-wrapper" class="crm-radio-wrapper crm-radio-wrapper-200px"><input class="" value="month" type="radio" id="CRM_QFID_month_is_recur_radio" name="is_recur_radio"><label for="CRM_QFID_month_is_recur_radio">Monthly</label></div>
<input class="payment_processor_nach crm-form-radio" value="6" type="radio" id="CRM_QFID_6_payment_processor_id" name="payment_processor_id" checked="checked">
我有这两组按钮,我想自动切换收音机。条件是我只能选择 1 个收音机。例如,当我选择“CRM_QFID_is_recur_radio”按钮时,应选择“CRM_QFID_4_ payment_processor_id”。
当我切换到 CRM_QFID_month_is_recur_radio 时,应选择“CRM_QFID_6_ payment_processor_id”。
在jquery中如何实现呢?我已尝试以下操作,但它没有切换:
$('input[name=is_recur_radio]').change(function() {
$("input[name=is_recur_radio]:checked").attr("id") == "CRM_QFID_is_recur_radio" ? $('input[name=payment_processor_id][value=6]').prop("disabled", false) : $('input[name=payment_processor_id][value=6]').prop("disabled", true);
$("input[name=is_recur_radio]:checked").attr("id") == "CRM_QFID_month_is_recur_radio" ? $('input[name=payment_processor_id][value=4]').prop("disabled", true) : $('input[name=payment_processor_id][value=4]').prop("disabled", false);
$('input[name=payment_processor_id][value=6]').prop('checked', false);
$('input[name=payment_processor_id][value=4]').prop('checked', false);
});