Search code examples
javascriptinputchecked

Wizard radio button checked not work and post?


I am not getting data from class which is selected - radio button not post.

Live example: https://www.kodjs.com/uyeol.php
All-Code jQuery: https://jsfiddle.net/8Lbsdduv/1/

$('[data-toggle="wizard-radio"]').click(function(){
        wizard = $(this).closest('.wizard-card');
        wizard.find('[data-toggle="wizard-radio"]').removeClass('active');
        $(this).addClass('active');
        $(wizard).find('[type="radio"]').removeAttr('checked');
        $(this).find('[type="radio"]').attr('checked','true');  

/*My code*/

$( "input" ).on( "click", function() {
  $( "#log" ).html( $( "input:checked" ).val());
});

Solution

  • Try replacing

    $(wizard).find('[type="radio"]').removeAttr('checked');
    $(this).find('[type="radio"]').attr('checked','true');
    

    with this

    $(wizard).find('[type="radio"]').prop('checked', false);
    $(this).find('[type="radio"]').prop('checked',true);