JS如何獲取和改變 單選按鈕radio選中的值

1、html:

<label style="font-size: 14px"><input id="input1"style="width:25px;height:13px;" type="radio" name="radio" value="否" checked/></label>
<label onclick="fun();" style="font-size: 14px"><input id="input2" style="width:25px;height:13px;" type="radio" name="radio" value="是" /></label>

2、JS
獲取選中的radios的值

var freshYN = $('input:radio:checked').val();//獲取選中的radio的值
//checked代表爲選中

3、confirm彈出框的使用

<script>//點擊radio“是”彈出窗口顯示:是否切換
        function fun(){            
             var r=confirm("確定切換至強制緩存狀態嗎?")
              if (r==true)
                {                }
              else
                {
                $("#input1").attr("checked",true);
                //取消,則將屬性設爲改變
                }
        }
    </script>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章