Javascript 使用Jquery Mobile检查和取消选中单选按钮

Javascript 使用Jquery Mobile检查和取消选中单选按钮,javascript,html,cordova,jquery-mobile,radio-button,Javascript,Html,Cordova,Jquery Mobile,Radio Button,我无法使用jquery mobile以编程方式选中一组复选框,我有以下代码: <div data-role="fieldcontain" id="div_radio" class="radiogroup"> <fieldset data-role="controlgroup"> <input type="radio" name="radio-pieces" id="radio-choice-1" value="3" checked="che

我无法使用jquery mobile以编程方式选中一组复选框,我有以下代码:

<div data-role="fieldcontain"  id="div_radio" class="radiogroup">
    <fieldset data-role="controlgroup">
        <input type="radio" name="radio-pieces" id="radio-choice-1" value="3" checked="checked" />
        <label for="radio-choice-1">1 to 3</label>

        <input type="radio" name="radio-pieces" id="radio-choice-2" value="5"  />
        <label for="radio-choice-2">4 to 5</label>

        <input type="radio" name="radio-pieces" id="radio-choice-3" value="6"  />
        <label for="radio-choice-3">over 5</label>
    </fieldset>
</div>
如何正确操作这些元素?取消选中所有复选框也可以正常工作:

$("input[type='radio']").attr("checked",false).checkboxradio("refresh");
似乎唯一起作用的复选框是最后一个。

这似乎不对。 不需要单引号输入[type=radio]是否正确。 我使用的是过时的版本(1.1.1)。 了解您正在使用的版本会有所帮助


请记住,这些都是单选按钮,一次只能选择一个。

它们都工作正常。您只需在组中的所有
输入电台
上触发
刷新

$(“input[type='radio']:first”).attr(“checked”、“checked”);
$(“输入[type='radio'])。复选框radio(“刷新”);

jsiddle在Jquery mobile单选按钮刷新中是。

,如下所示:

$(".iscfieldset input[type='radio']:first").attr("checked", "checked");


    $(".iscfieldset input[type='radio']").checkboxradio().checkboxradio("refresh"); 

试试这个对我来说很好的方法

除了:

$('#reset').click(function(){
    $('#Store').trigger("click").trigger("click"); // yes... twice
});

在jQuery Mobile 1.4.2上。

对于我来说,这样做可以取消选中整个无线电组:

$(".my_class").removeAttr("checked");
$(".my_class").checkboxradio("refresh");
$(".my_class").removeAttr("checked");
$(".my_class").checkboxradio("refresh");