我無法檢查一組複選框編程與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']:last").attr("checked",true).checkboxradio("refresh");
一切都運行完美,但沒有這項工作在所有:
$("input[type='radio']:first").attr("checked",true).checkboxradio("refresh");
$("input[type='radio']:eq(0)").attr("checked",true).checkboxradio("refresh");
$("input[type='radio']:eq(1)").attr("checked",true).checkboxradio("refresh");
$("input[type='radio']:eq(2)").attr("checked",true).checkboxradio("refresh");
我該如何正確操縱這些元素?取消選中所有複選框也可以正常工作:
$("input[type='radio']").attr("checked",false).checkboxradio("refresh");
看起來,唯一的複選框工作是最後一個。
任何幫助嗎?請 –