変更時にデバイスの向きを変更する2つのラジオボタンのセットがあります。
私が抱えている問題は、横向きのラジオボタンを選択すると機能しますが、縦向きのラジオボタンを再選択すると、横向きのアラートが表示され、同じままです。
これが私の試みです:
HTML:
<fieldset data-role="controlgroup">
<input type="radio" name="orientation" id="portrait" value="1" checked />
<label for="portrait">Portrait</label>
<input type="radio" name="orientation" id="landscape" value="2" />
<label for="landscape">Landscape Mode</label>
</fieldset>
JS:
$("input[name='orientation']").change(function() {
if ($("input[name='orienation']:checked").val() == '1') {
navigator.screenOrientation.set('portrait');
alert('portrait');
}
else if ($("input[name='orienation']:checked").val() == '2') {
navigator.screenOrientation.set('landscape');
alert('landscape');
}
})
jQueryとjQuery Mobileを使用しています