JavaScriptを使用してラジオボタンの値を設定しようとしています。しかし、私はそうすることができません。私がやろうとしたことは、そのうちの1つがすでに選択されている4つのラジオボタンを持つことでした。他のラジオ ボタンを選択して [更新] をクリックすると、デフォルトのラジオ ボタンが選択されます。
http://jsfiddle.net/ds345/Un8XK/1/
HTML:
<fieldset data-role="controlgroup" data-type="vertical">
<input type="radio" name="radio" id="x" data-theme="a" />
<label for="x" style="color: White">X</label>
<input type="radio" name="radio" id="y" onclick="axisonoff(this)" data-theme="a" />
<label for="y" style="color: White">Y</label>
<input type="radio" name="radio" id="z" data-theme="a" />
<label for="z" >Z</label>
<input type="radio" name="radio" id="none" data-theme="a" />
<label for="none" style="color: White">None</label>
</fieldset>
<button id = "Refresh" value="Refresh">Refresh</button>
JS:
$(document).ready(function () {
$("#none").attr("checked", true).checkboxradio("refresh"); // if this line is not present initially then it works for the 1st refresh.
});
$("#Refresh").click(function(){
$("#x").attr("checked", false).checkboxradio("refresh");
$("#y").attr("checked", false).checkboxradio("refresh");
$("#z").attr("checked", false).checkboxradio("refresh");
$("#none").attr("checked", true).checkboxradio("refresh");
});
非常に小さなことを見逃していると確信していますが、このアプローチが機能しない理由を理解できません。
使用ツール: Javascript、Jquery 1.9、JQuery mobile 1.3
ありがとう、
ディクシャ