以编程方式选择字段集中的单选按钮

kol*_*fos 4 jquery jquery-mobile

我有一个带收音机的字段集(问题的选项),我想在页面显示上以编程方式预选选项控件组中的单选按钮,这里是控件组:

<fieldset data-role="controlgroup" id="options">
    <input type="radio" name="radio-choice-1" id="optiona" value="a"
                                                           checked="checked" />
    <label for="optiona" id="labela">Ondo</label>
    <input type="radio" name="radio-choice-1" id="optionb" value="b" />
    <label for="optionb">Lagos</label>
    <input type="radio" name="radio-choice-1" id="optionc" value="c" />
    <label for="optionc">Abuja</label>
    <input type="radio" name="radio-choice-1" id="optiond" value="d" />
    <label for="optiond">Kogi</label>
    <input type="radio" name="radio-choice-1" id="optione" value="e" />
    <label for="optione">Niger</label>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

我尝试过以下方法:

var sel = questions[indexNo].correct;
$("#option" + sel).prop("checked", true)
$("#option"+ sel).is(":checked");
Run Code Online (Sandbox Code Playgroud)

Gaj*_*res 5

工作示例:http://jsfiddle.net/Gajotres/aawNj/

$(document).on('pagebeforeshow', '#index', function(){ 
    $( "#optiona" ).prop( "checked", false ).checkboxradio( "refresh" );    
    $( "#optionb" ).prop( "checked", true ).checkboxradio( "refresh" );
});
Run Code Online (Sandbox Code Playgroud)

或另一个工作示例:http://jsfiddle.net/Gajotres/EFzxj/

$(document).on('pagebeforeshow', '#index', function(){ 
    $( "#optionb" ).prop( "checked", true );  
    $('#content').trigger('create');
});
Run Code Online (Sandbox Code Playgroud)