Jquery mobile radio已选中,但未显示

Jquery mobile radio已选中,但未显示,jquery,jquery-mobile,Jquery,Jquery Mobile,Javascript决定页面加载时选中哪个按钮。代码成功地检测到了这一点,但“选中”按钮不显示 我已将.checkboxradio(“刷新”)添加到单选组和单个单选按钮中,但没有效果。这里有一个演示: .按钮(“刷新”)导致错误 <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <met

Javascript决定页面加载时选中哪个按钮。代码成功地检测到了这一点,但“选中”按钮不显示

我已将.checkboxradio(“刷新”)添加到单选组和单个单选按钮中,但没有效果。这里有一个演示:

.按钮(“刷新”)导致错误

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Tax</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
    <link href="css/tax.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>  
</head>
<body>
<div id="page2" data-role="page"  data-add-back-btn="true">
    <div data-role="content">
        <div id="proCG">
            <fieldset data-role="controlgroup" data-mini="true">
                <legend>Tax Capital Gains </legend>
                <input type="radio" name="choProCG" id="radProCG1" value="1" />
                <label for="radProCG1">as ordinary income</label>
                <input type="radio" name="choProCG" id="radProCG2" value="0" />
                <label for="radProCG2">at a separate rate</label>
            </fieldset>
        </div>
        <div id="txthere"></div>
    </div>
</div>      
</body>
</html> 

<script>
$('#page2').live('pageinit', function(event) {    
    console.log('here');
    $("#radProCG2").prop("checked", true).checkboxradio("refresh");
    $('input[name=choProCG]').checkboxradio("refresh");
    $('#txthere').append('duck');
    $('#txthere').append($('input[name=choProCG]:checked').val());
    $('input[name=choProCG]').change( function(e){
        $('#txthere').append(this.value);
        $('#txthere').append('frog');

    }); 
});
</script>

税
税收资本收益
作为普通收入
另收费
$('#page2').live('pageinit',函数(事件){
console.log('here');
$(“#radProCG2”).prop(“选中”,为真)。checkboxradio(“刷新”);
$('input[name=choProCG]')。checkboxradio(“刷新”);
$('#txthere')。追加('duck');
$('#txthere').append($('input[name=choProCG]:checked').val();
$('input[name=choProCG]')。更改(函数(e){
$('#txthere').append(this.value);
$(“#txthere”).append('frog');
}); 
});

在html中尝试此代码

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <legend>Choose a pet:</legend>
            <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
            <label for="radio-choice-1">Cat</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
            <label for="radio-choice-2">Dog</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3"  />
            <label for="radio-choice-3">Hamster</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-4" value="choice-4"  />
            <label for="radio-choice-4">Lizard</label>
    </fieldset>
</div>

选择宠物:
猫
狗
仓鼠
蜥蜴

在html中尝试此代码

<div data-role="fieldcontain">
    <fieldset data-role="controlgroup">
        <legend>Choose a pet:</legend>
            <input type="radio" name="radio-choice-1" id="radio-choice-1" value="choice-1" checked="checked" />
            <label for="radio-choice-1">Cat</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-2" value="choice-2"  />
            <label for="radio-choice-2">Dog</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-3" value="choice-3"  />
            <label for="radio-choice-3">Hamster</label>

            <input type="radio" name="radio-choice-1" id="radio-choice-4" value="choice-4"  />
            <label for="radio-choice-4">Lizard</label>
    </fieldset>
</div>

选择宠物:
猫
狗
仓鼠
蜥蜴
试试这个

下面的代码

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Tax</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
    <link href="css/tax.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>  
</head>
<body>
<div id="page2" data-role="page"  data-add-back-btn="true">
    <div data-role="content">
        <div id="proCG">
            <fieldset data-role="controlgroup" data-mini="true">
                <legend>Tax Capital Gains </legend>
                <input type="radio" name="choProCG" id="radProCG1" value="1" />
                <label for="radProCG1">as ordinary income</label>
                <input type="radio" name="choProCG" id="radProCG2" value="0" />
                <label for="radProCG2">at a separate rate</label>
            </fieldset>
        </div>
        <div id="txthere"></div>
    </div>
</div>      
</body>
</html> 

<script>

$('#page2').live('pageinit', function(event) {  

    console.log('here');
    $("#radProCG2").attr("checked", true).checkboxradio("refresh");
    $('input[name=choProCG]').checkboxradio("refresh");
    $('#txthere').append('duck');
    $('#txthere').append($('input[name=choProCG]:checked').val());
    $('input[name=choProCG]').change( function(e){
        $('#txthere').append(this.value);
        $('#txthere').append('frog');

    }); 
});
</script>​

税
税收资本收益
作为普通收入
另收费
$('#page2').live('pageinit',函数(事件){
console.log('here');
$(“#radProCG2”).attr(“选中”,为真)。checkboxradio(“刷新”);
$('input[name=choProCG]')。checkboxradio(“刷新”);
$('#txthere')。追加('duck');
$('#txthere').append($('input[name=choProCG]:checked').val();
$('input[name=choProCG]')。更改(函数(e){
$('#txthere').append(this.value);
$(“#txthere”).append('frog');
}); 
});
​
试试这个

下面的代码

<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Tax</title> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
    <link href="css/tax.css" rel="stylesheet" type="text/css" />
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>  
</head>
<body>
<div id="page2" data-role="page"  data-add-back-btn="true">
    <div data-role="content">
        <div id="proCG">
            <fieldset data-role="controlgroup" data-mini="true">
                <legend>Tax Capital Gains </legend>
                <input type="radio" name="choProCG" id="radProCG1" value="1" />
                <label for="radProCG1">as ordinary income</label>
                <input type="radio" name="choProCG" id="radProCG2" value="0" />
                <label for="radProCG2">at a separate rate</label>
            </fieldset>
        </div>
        <div id="txthere"></div>
    </div>
</div>      
</body>
</html> 

<script>

$('#page2').live('pageinit', function(event) {  

    console.log('here');
    $("#radProCG2").attr("checked", true).checkboxradio("refresh");
    $('input[name=choProCG]').checkboxradio("refresh");
    $('#txthere').append('duck');
    $('#txthere').append($('input[name=choProCG]:checked').val());
    $('input[name=choProCG]').change( function(e){
        $('#txthere').append(this.value);
        $('#txthere').append('frog');

    }); 
});
</script>​

税
税收资本收益
作为普通收入
另收费
$('#page2').live('pageinit',函数(事件){
console.log('here');
$(“#radProCG2”).attr(“选中”,为真)。checkboxradio(“刷新”);
$('input[name=choProCG]')。checkboxradio(“刷新”);
$('#txthere')。追加('duck');
$('#txthere').append($('input[name=choProCG]:checked').val();
$('input[name=choProCG]')。更改(函数(e){
$('#txthere').append(this.value);
$(“#txthere”).append('frog');
}); 
});
​