<tfoot id='xAX1F'></tfoot>

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

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

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

        如何获取选定单选按钮的值?

        How to get value of selected radio button?(如何获取选定单选按钮的值?)
          <tbody id='wqHTV'></tbody>

          <tfoot id='wqHTV'></tfoot>

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

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

          1. <legend id='wqHTV'><style id='wqHTV'><dir id='wqHTV'><q id='wqHTV'></q></dir></style></legend>
            • <bdo id='wqHTV'></bdo><ul id='wqHTV'></ul>
                  本文介绍了如何获取选定单选按钮的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想从一组单选按钮中获取选定的值.

                  I want to get the selected value from a group of radio buttons.

                  这是我的 HTML:

                  <div id="rates">
                    <input type="radio" id="r1" name="rate" value="Fixed Rate"> Fixed Rate
                    <input type="radio" id="r2" name="rate" value="Variable Rate"> Variable Rate
                    <input type="radio" id="r3" name="rate" value="Multi Rate" checked="checked"> Multi Rate  
                  </div>
                  

                  这是我的 js:

                  var rates = document.getElementById('rates').value;
                  var rate_value;
                  if(rates =='Fixed Rate'){
                      rate_value = document.getElementById('r1').value;
                      
                  }else if(rates =='Variable Rate'){
                      rate_value = document.getElementById('r2').value;
                      
                  }else if(rates =='Multi Rate'){
                      rate_value = document.getElementById('r3').value;
                  }  
                  
                  document.getElementById('results').innerHTML = rate_value;
                  

                  我一直不确定.

                  推荐答案

                  var rates = document.getElementById('rates').value;
                  

                  rates 元素是一个 div,所以它没有值.这可能是 undefined 的来源.

                  The rates element is a div, so it won't have a value. This is probably where the undefined is coming from.

                  checked 属性会告诉你元素是否被选中:

                  The checked property will tell you whether the element is selected:

                  if (document.getElementById('r1').checked) {
                    rate_value = document.getElementById('r1').value;
                  }
                  

                  或者

                  $("input[type='radio'][name='rate']:checked").val();
                  

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

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

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  Ordinals in words javascript(javascript中的序数)
                  • <bdo id='SsfH9'></bdo><ul id='SsfH9'></ul>
                    <legend id='SsfH9'><style id='SsfH9'><dir id='SsfH9'><q id='SsfH9'></q></dir></style></legend>

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

                            <tbody id='SsfH9'></tbody>

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