• <legend id='C20nM'><style id='C20nM'><dir id='C20nM'><q id='C20nM'></q></dir></style></legend>

      • <bdo id='C20nM'></bdo><ul id='C20nM'></ul>

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

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

        Javascript如何更改单选按钮标签文本?

        时间:2023-10-21

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

            <legend id='vZrev'><style id='vZrev'><dir id='vZrev'><q id='vZrev'></q></dir></style></legend>
              <tbody id='vZrev'></tbody>
          1. <tfoot id='vZrev'></tfoot>

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

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

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

                  问题描述

                  I want to change the text of the label which is associated with the radiobutton id="male". I have tried various ways to do it, but i can't make it work. I want to change the text "Male" in the label associated to the radio button.

                    <input type="radio" name="sex" id="male" value="male">
                          <label for="male">Male</label>
                    </input>
                  
                   <input type="button" value="Submit" onclick = test()>
                  
                  <script>
                  
                  function test()
                  {
                     var r = document.getElementById("male");
                     r.nextSibling.data = "adaS";
                  //  r.nextSibling.nodeValue = "adaS";     // have tried all these ways
                  //  r.childNodes[0].value= "adaS";
                  //  r.childNodes[0].innerHTML= "adaS";
                  //   r.parentNode.childNodes[1].innerHTML= "adaS";
                  
                  }
                  
                  </script>
                  

                  please suggest some working way to change the text "Male" in the label.

                  解决方案

                  You can use

                  var r = document.getElementsByTagName("label")   
                  

                  to select all the label element in your page and then use

                  r[0].innerHTML ="new text" 
                  

                  to select first label and set the text to "next text" in your test() function

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

                  上一篇:JavaScript 单选按钮确认 下一篇:通过单击标签来切换 HTML 单选按钮

                  相关文章

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

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

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

                      <tfoot id='OT0xg'></tfoot>