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

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

      <tfoot id='XYBjO'></tfoot>

        jQuery,检查是否选择了所有单选按钮组

        jQuery, check to see if all radiobutton groups are selected(jQuery,检查是否选择了所有单选按钮组)

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

                  <tbody id='qxQag'></tbody>

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

                • <legend id='qxQag'><style id='qxQag'><dir id='qxQag'><q id='qxQag'></q></dir></style></legend>
                • <tfoot id='qxQag'></tfoot>
                  <i id='qxQag'><tr id='qxQag'><dt id='qxQag'><q id='qxQag'><span id='qxQag'><b id='qxQag'><form id='qxQag'><ins id='qxQag'></ins><ul id='qxQag'></ul><sub id='qxQag'></sub></form><legend id='qxQag'></legend><bdo id='qxQag'><pre id='qxQag'><center id='qxQag'></center></pre></bdo></b><th id='qxQag'></th></span></q></dt></tr></i><div id='qxQag'><tfoot id='qxQag'></tfoot><dl id='qxQag'><fieldset id='qxQag'></fieldset></dl></div>
                  本文介绍了jQuery,检查是否选择了所有单选按钮组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有几个单选按钮组,当它们被选中时我需要运行一个脚本.

                  我使用以下脚本来检查其中一个是否被选中,如果没有,则对其进行着色.

                  如何编写代码,以便在检查所有单选按钮组后,运行脚本.

                  检查单选按钮组是否被选中的代码:

                  $('.aQuestion').each(function(){if($(this).find('input[type="radio"]:checked').length > 0){警报(检查");}别的{警报(未检查");}});

                  单选按钮组(大约有 90 个):

                  提前致谢:D

                  解决方案

                  假设每个问题只有一个单选按钮组,您不需要迭代问题以找出它们都被选中:

                  p>

                  var $questions = $(".aQuestion");if($questions.find("input:radio:checked").length === $questions.length) {//全部检查}

                  jsFiddle 演示了上述内容.

                  I have several radiobuttongroups, and I need to run a script when they are checked.

                  I use the following script to check if one of them is checked, if not, then color it.

                  How can I make the code, so that when all of the radiobuttongroups are checked, then run script.

                  The code that checks if the radiobuttongroups are checked:

                  $('.aQuestion').each(function(){
                    if($(this).find('input[type="radio"]:checked').length > 0)
                      {
                         alert("checked");
                      }
                    else
                      {
                         alert("not checked");
                      }    
                  });
                  

                  The radiobuttongroups (there is about 90 of them):

                  <div class='aQuestion' id='div1'>
                      <STRONG>1. </STRONG>
                      <STRONG>Question</STRONG></br>
                      <INPUT TYPE='radio' NAME='grp1' VALUE='0'>answer 1</br>
                      <INPUT TYPE='radio' NAME='grp1' VALUE='1'>answer 2</br>
                      <INPUT TYPE='radio' NAME='grp1' VALUE='2'>answer 3</br>
                      <INPUT TYPE='radio' NAME='grp1' VALUE='3'>answer 4</br>
                      <INPUT TYPE='radio' NAME='grp1' VALUE='4'>answer 5
                  </div>
                  
                  <div class='aQuestion' id='div2'>
                      <STRONG>2. </STRONG>
                      <STRONG>Question</STRONG></br>
                      <INPUT TYPE='radio' NAME='grp2' VALUE='0'>answer 1</br>
                      <INPUT TYPE='radio' NAME='grp2' VALUE='1'>answer 2</br>
                      <INPUT TYPE='radio' NAME='grp2' VALUE='2'>answer 3</br>
                      <INPUT TYPE='radio' NAME='grp2' VALUE='3'>answer 4</br>
                      <INPUT TYPE='radio' NAME='grp2' VALUE='4'>answer 5
                  </div>
                  

                  Thanks in advance :D

                  解决方案

                  Assuming there is only one radio button group per question, you don't need to iterate the questions in order to find out they're all selected:

                  var $questions = $(".aQuestion");
                  if($questions.find("input:radio:checked").length === $questions.length) {
                      // All Checked
                  }
                  

                  jsFiddle which demonstrates the above.

                  这篇关于jQuery,检查是否选择了所有单选按钮组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 自动选择特定的单选按钮?)

                    <tbody id='R99Br'></tbody>
                    <bdo id='R99Br'></bdo><ul id='R99Br'></ul>

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

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

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