The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Assign a class to a checked radio button

Labels

This Discussion is public

Notifications

Hello,

I am trying to assign a class to a selected radio button but no matter what I try, I can't get it to work.

I have attempted using this jQuery code snippet:

$('input[type=radio]').click(function(){
$('label').removeClass('active');
$(this).next('label').addClass('active');
});

but nothing seems to happen.

When I inspect element, I do not see the :checked selector anywhere, so I am unable to use this CSS snippet:.frm_radio input[type=radio]:checked {background-color: #fff;}
Any help would greatly appreciated!

I figured it out! Added the following to the After Fields in Customize HTML:

jQuery(".horizontal_radio").each(function() {
jQuery(this).find('.frm_radio').each(function() {
// jQuery('input[id^="field_"]').hide();
var getID = jQuery(this).find('input[id^="field_"]').attr('id');
var getCheckStatus = jQuery('#'+getID+'').prop('the-choice');
if(getCheckStatus == true){
jQuery('#'+getID+'').parent().addClass('the-choice');
}
});
});
jQuery(".frm_radio label").click(function() {
jQuery(this).parent().parent().find('.frm_radio').find('label').removeClass('the-choice');
jQuery(this).addClass('the-choice');
});

Discussion closed.