1. <tfoot id='RFF3u'></tfoot>
        <bdo id='RFF3u'></bdo><ul id='RFF3u'></ul>

      1. <small id='RFF3u'></small><noframes id='RFF3u'>

        <i id='RFF3u'><tr id='RFF3u'><dt id='RFF3u'><q id='RFF3u'><span id='RFF3u'><b id='RFF3u'><form id='RFF3u'><ins id='RFF3u'></ins><ul id='RFF3u'></ul><sub id='RFF3u'></sub></form><legend id='RFF3u'></legend><bdo id='RFF3u'><pre id='RFF3u'><center id='RFF3u'></center></pre></bdo></b><th id='RFF3u'></th></span></q></dt></tr></i><div id='RFF3u'><tfoot id='RFF3u'></tfoot><dl id='RFF3u'><fieldset id='RFF3u'></fieldset></dl></div>
        <legend id='RFF3u'><style id='RFF3u'><dir id='RFF3u'><q id='RFF3u'></q></dir></style></legend>
      2. 在 JavaScript 中,如何获取页面中具有给定名称的所有单选按钮?

        In JavaScript, how can I get all radio buttons in the page with a given name?(在 JavaScript 中,如何获取页面中具有给定名称的所有单选按钮?)

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

                  <bdo id='85Oej'></bdo><ul id='85Oej'></ul>
                  <tfoot id='85Oej'></tfoot>

                  <small id='85Oej'></small><noframes id='85Oej'>

                    <tbody id='85Oej'></tbody>
                  本文介绍了在 JavaScript 中,如何获取页面中具有给定名称的所有单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  正如标题所说,在 JavaScript 中获取所有单选按钮的最佳方式是什么?具有给定名称的页面?最终我将使用它来确定选择了哪个特定的单选按钮,所以用另一种方式来表达这个问题:

                  Like the title says, what's the best way in JavaScript to get all radio buttons on a page with a given name? Ultimately I will use this to determine which specific radio button is selected, so another way to phrase the question:

                  给定 JavaScript 中的字符串变量,我如何知道当前选择了哪个带有该字符串的确切单选按钮输入元素(如果有),因为它的名称是?

                  Given a string variable in JavaScript, how can I tell which exact radio button input element (if any) with that string as it's name is currently selected?

                  使用 jQuery.如果您想提供 jQuery 答案,请继续.其他人可能会发现它很有用.但这对我没有帮助,我也不会投票.

                  I'm not using jQuery. If you want to provide a jQuery answer, go ahead. Someone else might find it useful. But it won't help me and I won't upvote it.

                  推荐答案

                  您可以使用 document.getElementsByName(),传递无线电组的名称,然后遍历它们检查 已检查 属性,例如类似:

                  You can use document.getElementsByName(), passing the name of the radio group, then loop over them inspecting the checked attribute, e.g. something like:

                  function getCheckedValue( groupName ) {
                      var radios = document.getElementsByName( groupName );
                      for( i = 0; i < radios.length; i++ ) {
                          if( radios[i].checked ) {
                              return radios[i].value;
                          }
                      }
                      return null;
                  }
                  

                  这篇关于在 JavaScript 中,如何获取页面中具有给定名称的所有单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  keeping radio buttons checked after form submit(表单提交后保持选中单选按钮)
                  Styling radio button - not work in IE and Firefox(样式单选按钮 - 在 IE 和 Firefox 中不起作用)
                  Toggle HTML radio button by clicking its label(通过单击标签来切换 HTML 单选按钮)
                  Javascript how to change radio button label text?(Javascript如何更改单选按钮标签文本?)
                  JavaScript radio button confirmation(JavaScript 单选按钮确认)
                  How can I automatically select specific radio buttons with Greasemonkey?(如何使用 Greasemonkey 自动选择特定的单选按钮?)

                      <bdo id='PWSLC'></bdo><ul id='PWSLC'></ul>

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

                          • <small id='PWSLC'></small><noframes id='PWSLC'>

                            <legend id='PWSLC'><style id='PWSLC'><dir id='PWSLC'><q id='PWSLC'></q></dir></style></legend>