• Resolved alexbertocchi

    (@alexbertocchi)


    Hi all,
    I created a form and I put five radio buttons.

    My problem is that I need to assign a class to each option to track user behaviuor

    How can I do it??

    Thanks in advance

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hell @alexbertocchi

    You can use jQuery to assign the radio button value as class:

    jQuery( 'form.wpcf7-form input' ).each(function(){
      var name = jQuery( this).attr( 'name' );
      var type = jQuery( this ).attr('type');
      if( name == 'your-field-name' && type == 'radio' ) {
        jQuery( this ).addClass( jQuery( this ).val() );
      }
    });
    Thread Starter alexbertocchi

    (@alexbertocchi)

    Thanks a lot!
    ALex

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add a class to radio button’ is closed to new replies.