2011-08-12 25 views
1

如何強制一個收音機箱被檢查jquery mobile中的值? 我認爲這與class = ui-btn-active有關。強制一個收音機箱被檢查jquery mobile中的值

<input type='radio' name='myradio' id='radio-choice-1' value='1' /><label for='radio-choice-1'>Station 1</label> 
<input type='radio' name='myradio' id='radio-choice-2' checked value='2' /><label for='radio-choice-2'>Station 2</label> 
<input type='radio' name='myradio' id='radio-choice-3' value='3' /><label for='radio-choice-3'>Station 3</label> 

回答

3

我不確定'force'是什麼意思 - 你問的是如何以編程方式改變單選按鈕的狀態?使用jQuery Mobile,您必須在更新其屬性後刷新單選按鈕,以便更新UI。 From the docs

$("input[type='radio']").attr("checked",true).checkboxradio("refresh"); 

還要注意的是與HTML4,boolean attributesdisabledchecked啓用時把他們的名字作爲值。所以簡單地輸入checked是無效的,但必須是checked='checked'