<small id='Gc8Ka'></small><noframes id='Gc8Ka'>

    1. <tfoot id='Gc8Ka'></tfoot>

      1. <legend id='Gc8Ka'><style id='Gc8Ka'><dir id='Gc8Ka'><q id='Gc8Ka'></q></dir></style></legend>

        <i id='Gc8Ka'><tr id='Gc8Ka'><dt id='Gc8Ka'><q id='Gc8Ka'><span id='Gc8Ka'><b id='Gc8Ka'><form id='Gc8Ka'><ins id='Gc8Ka'></ins><ul id='Gc8Ka'></ul><sub id='Gc8Ka'></sub></form><legend id='Gc8Ka'></legend><bdo id='Gc8Ka'><pre id='Gc8Ka'><center id='Gc8Ka'></center></pre></bdo></b><th id='Gc8Ka'></th></span></q></dt></tr></i><div id='Gc8Ka'><tfoot id='Gc8Ka'></tfoot><dl id='Gc8Ka'><fieldset id='Gc8Ka'></fieldset></dl></div>
          <bdo id='Gc8Ka'></bdo><ul id='Gc8Ka'></ul>

        如何通过单击取消选中单选按钮?

        How to make a radio button unchecked by clicking it?(如何通过单击取消选中单选按钮?)
        • <legend id='kXOho'><style id='kXOho'><dir id='kXOho'><q id='kXOho'></q></dir></style></legend>
            <tfoot id='kXOho'></tfoot>

                <bdo id='kXOho'></bdo><ul id='kXOho'></ul>
              • <i id='kXOho'><tr id='kXOho'><dt id='kXOho'><q id='kXOho'><span id='kXOho'><b id='kXOho'><form id='kXOho'><ins id='kXOho'></ins><ul id='kXOho'></ul><sub id='kXOho'></sub></form><legend id='kXOho'></legend><bdo id='kXOho'><pre id='kXOho'><center id='kXOho'></center></pre></bdo></b><th id='kXOho'></th></span></q></dt></tr></i><div id='kXOho'><tfoot id='kXOho'></tfoot><dl id='kXOho'><fieldset id='kXOho'></fieldset></dl></div>

                  <tbody id='kXOho'></tbody>
                • <small id='kXOho'></small><noframes id='kXOho'>

                  本文介绍了如何通过单击取消选中单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  与复选框不同,用户无法在单击单选按钮后取消选择它们.有什么方法可以使用 Javascript 以编程方式切换它们?最好不要使用 jQuery.

                  Unlike check boxes, it is impossible for the user to deselect radio buttons once they are clicked. Is there any way so that they can be toggled programmatically using Javascript? This would be preferably without using jQuery.

                  推荐答案

                  你可以像这样设置 HTML 对象的属性 checkedfalse:

                  You can set HTML object's property checked to false like this:

                  document.getElementById('desiredInput').checked = false;
                  


                  示例

                  纯 JavaScript:


                  Examples

                  Plain JavaScript:

                  var radios = document.getElementsByTagName('input');
                  for(i=0; i<radios.length; i++ ) {
                      radios[i].onclick = function(e) {
                          if(e.ctrlKey || e.metaKey) {
                              this.checked = false;
                          }
                      }
                  }

                  <input type="radio" name="test" value="1" />
                  <input type="radio" name="test" value="2" checked="checked" />
                  <input type="radio" name="test" value="3" />

                  $('input').click(function(e){
                      if (e.ctrlKey || e.metaKey) {
                          $(this).prop('checked', false);
                      }
                  });

                  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
                  <input type="radio" name="test" value="1" />
                  <input type="radio" name="test" value="2" checked="checked" />
                  <input type="radio" name="test" value="3" />

                  这篇关于如何通过单击取消选中单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  keeping radio buttons checked after form submit(表单提交后保持选中单选按钮)
                  Styling radio button - not work in IE and Firefox(样式单选按钮 - 在 IE 和 Firefox 中不起作用)
                  Bootstrap radio button quot;checkedquot; flag(Bootstrap 单选按钮“已选中旗帜)
                  Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                  Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                  JavaScript radio button confirmation(JavaScript 单选按钮确认)

                    • <bdo id='CyOl7'></bdo><ul id='CyOl7'></ul>
                      <legend id='CyOl7'><style id='CyOl7'><dir id='CyOl7'><q id='CyOl7'></q></dir></style></legend>

                      <small id='CyOl7'></small><noframes id='CyOl7'>

                          <tfoot id='CyOl7'></tfoot>
                            <tbody id='CyOl7'></tbody>
                          <i id='CyOl7'><tr id='CyOl7'><dt id='CyOl7'><q id='CyOl7'><span id='CyOl7'><b id='CyOl7'><form id='CyOl7'><ins id='CyOl7'></ins><ul id='CyOl7'></ul><sub id='CyOl7'></sub></form><legend id='CyOl7'></legend><bdo id='CyOl7'><pre id='CyOl7'><center id='CyOl7'></center></pre></bdo></b><th id='CyOl7'></th></span></q></dt></tr></i><div id='CyOl7'><tfoot id='CyOl7'></tfoot><dl id='CyOl7'><fieldset id='CyOl7'></fieldset></dl></div>