Search code examples
javascriptjqueryradio-button

JQuery Mobile : Radio Button Doesn't Reflect


I've created the radio button for jQuery mobile, I already declare the variable and the value, but why is not reflect, can anybody help I tried many time with different code but still didn't work.

Here is live code

https://jsfiddle.net/h47Lfnbp

var type = "Contractor";
$('input[name=CustCat]').filter('[value=Contractor]').attr('checked', true);

Many thank ahead.


Solution

  • http://jsfiddle.net/techsin/snj4heoz/

    here you need to remove ui-radio-off class then ad ui-radio-on class.

    var inputs = $('input[name=CustCat]');
    
    inputs.filter('[value=' + type + ']').first().attr('checked', true).siblings('label').removeClass('ui-radio-off').addClass('ui-radio-on');